Submission #3807289
Source Code Expand
using System.Collections.Generic; using System.Linq; using static System.Console; class Program { static void Main() { var n = NextInt(); var k = NextInt(); var a = new int[n]; foreach (var i in Enumerable.Range(0, n)) { a[i] = NextInt(); } var ans = 0L; var cnt = 0L; foreach (var i in Enumerable.Range(0, k)) { cnt += a[i]; } foreach (var i in Enumerable.Range(0, n - k + 1)) { if (i != 0) { cnt += a[i + k - 1] - a[i - 1]; } ans += cnt; } WriteLine(ans); } static int NextInt() { return int.Parse(NextString()); } static string NextString() { var result = new List<char>(); while (true) { int next = Read(); if (next < 0) { break; } var nextChar = (char)next; if (!char.IsWhiteSpace(nextChar)) { result.Add(nextChar); } else if (nextChar != '\r') { break; } } return string.Join("", result); } }
Submission Info
Submission Time | |
---|---|
Task | C - 総和 |
User | ToshiroYanagi |
Language | C# (Mono 4.6.2.0) |
Score | 100 |
Code Size | 1336 Byte |
Status | AC |
Exec Time | 204 ms |
Memory | 17596 KB |
Judge Result
Set Name | sample | subtask1 | subtask2 | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 50 / 50 | 50 / 50 | ||||||
Status |
|
|
|
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 | 25 ms | 11220 KB |
01.txt | AC | 25 ms | 11220 KB |
02.txt | AC | 25 ms | 11220 KB |
03.txt | AC | 26 ms | 9172 KB |
04.txt | AC | 26 ms | 9172 KB |
05.txt | AC | 26 ms | 11220 KB |
06.txt | AC | 27 ms | 11220 KB |
07.txt | AC | 26 ms | 11220 KB |
08.txt | AC | 27 ms | 11220 KB |
09.txt | AC | 27 ms | 11220 KB |
10.txt | AC | 27 ms | 11220 KB |
11.txt | AC | 194 ms | 17596 KB |
12.txt | AC | 194 ms | 13500 KB |
13.txt | AC | 193 ms | 13500 KB |
14.txt | AC | 194 ms | 13500 KB |
15.txt | AC | 197 ms | 15456 KB |
16.txt | AC | 194 ms | 17596 KB |
17.txt | AC | 204 ms | 17436 KB |
18.txt | AC | 78 ms | 17504 KB |
19.txt | AC | 194 ms | 13500 KB |
sample01.txt | AC | 25 ms | 13268 KB |
sample02.txt | AC | 25 ms | 11220 KB |