Submission #40535


ソースコード

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
33
34
35
#include <iostream>
#include <cstdio>
using namespace std;
int sum[1000005];
int main()
{
int n, m;
int a, b;
int data;
int i, j;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &sum[i]);
sum[i] += sum[i - 1];
}
for (i = 0; i <= n; i++) {
if (i) putchar(' ');
printf("%d", sum[i]);
}
putchar('\n');
scanf("%d", &m);
for (i = 0; i < m; i++) {
scanf("%d %d", &a, &b);
printf("%d\n", sum[b] - sum[a - 1]);
}
return 0;
}

ステータス

項目 データ
問題 0733 - プログラミング入門:累積和
ユーザー名 ei1710
投稿日時 2018-08-03 10:14:07
言語 C++17
状態 Accepted
得点 5
ソースコード長 572 Byte
最大実行時間 497 ms
最大メモリ使用量 104708 KB

セット

セット 得点 Cases
1 ALL 5 / 5 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 170 ms 15836 KB
1
Input02 AC 141 ms 27524 KB
1
Input03 AC 188 ms 40876 KB
1
Input04 AC 497 ms 72792 KB
1
Input05 AC 456 ms 104708 KB
1