Submission #00030


ソースコード

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
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
using namespace std;
int main() {
int n, k, x = 0;
cin >> n >> k;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n - k; i++) {
int sum = 0;
for (int j = i; j < i + k; j++) {
sum += a[j];
}
x = max(sum, x);
}
cout << x << "\n";
return(0);
}

ステータス

項目 データ
問題 0006 - 最大の和
ユーザー名 woody_1227
投稿日時 2022-07-19 16:37:11
言語 C++17
状態 Accepted
得点 1
ソースコード長 490 Byte
最大実行時間 984 ms
最大メモリ使用量 1884 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
2007-ho-t1-in1 AC 41 ms 604 KB
1
2007-ho-t1-in2 AC 21 ms 580 KB
2
2007-ho-t1-in3 AC 24 ms 548 KB
3
2007-ho-t1-in4 AC 414 ms 1280 KB
4
2007-ho-t1-in5 AC 984 ms 1884 KB
5