Submission #3807330


Source Code Expand

Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim n As Integer = NextInt()
        Dim k As Integer = NextInt()
        Dim a(n - 1) As Integer

        For i As Integer = 0 To n - 1
            a(i) = NextInt()
        Next

        Dim ans, cnt As Long
        For i As Integer = 0 To k - 1
            cnt += a(i)
        Next

        For i As Integer = 0 To n - k
            If i <> 0 Then cnt += a(i + k - 1) - a(i - 1)
            ans += cnt
        Next

        WriteLine(ans)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module

Submission Info

Submission Time
Task C - 総和
User ToshiroYanagi
Language Visual Basic (Mono 4.0.1)
Score 100
Code Size 1149 Byte
Status AC
Exec Time 178 ms
Memory 26952 KB

Judge Result

Set Name sample subtask1 subtask2
Score / Max Score 0 / 0 50 / 50 50 / 50
Status
AC × 2
AC × 13
AC × 24
Set Name Test Cases
sample sample01.txt, sample02.txt
subtask1 00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, sample01.txt, sample02.txt
subtask2 00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample01.txt, sample02.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
00.txt AC 47 ms 18384 KB
01.txt AC 47 ms 17872 KB
02.txt AC 47 ms 17872 KB
03.txt AC 48 ms 17872 KB
04.txt AC 49 ms 19920 KB
05.txt AC 48 ms 17872 KB
06.txt AC 49 ms 19920 KB
07.txt AC 49 ms 17872 KB
08.txt AC 48 ms 17872 KB
09.txt AC 48 ms 17872 KB
10.txt AC 48 ms 19920 KB
11.txt AC 166 ms 22748 KB
12.txt AC 163 ms 20820 KB
13.txt AC 167 ms 20824 KB
14.txt AC 168 ms 24620 KB
15.txt AC 167 ms 26952 KB
16.txt AC 167 ms 22860 KB
17.txt AC 178 ms 22852 KB
18.txt AC 105 ms 20812 KB
19.txt AC 161 ms 20824 KB
sample01.txt AC 47 ms 17872 KB
sample02.txt AC 47 ms 20560 KB