Submission #00003


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
int s[100000];
cin >> n >> k;
for(int i = 0; i < n; ++i) {
cin >> s[i];
}
int ans;
int sum = 0;
for(int i = 0; i < k; ++i) {
sum += s[i];
}
ans = sum;
for(int i = 0; i < n - k; ++i) {
sum -= s[i];
sum += s[i + k];
ans = max(ans, sum);
}
cout << ans << endl;
}

ステータス

項目 データ
問題 0001 - 最大の和
ユーザー名 ei1503
投稿日時 2017-02-03 16:05:53
言語 C++11
状態 Accepted
得点 100
ソースコード長 463 Byte
最大実行時間 41 ms
最大メモリ使用量 860 KB

セット

セット 得点 Cases
1 set1 20 / 20 *in1
2 set2 20 / 20 *in2
3 set3 20 / 20 *in3
4 set4 20 / 20 *in4
5 set5 20 / 20 *in5

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
2007-ho-t1-in1 AC 18 ms 480 KB
1
2007-ho-t1-in2 AC 20 ms 712 KB
2
2007-ho-t1-in3 AC 19 ms 560 KB
3
2007-ho-t1-in4 AC 35 ms 644 KB
4
2007-ho-t1-in5 AC 41 ms 860 KB
5