Submission #40986


ソースコード

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 sum[1000001];
int main()
{
int n, m;
int a, b;
int data;
scanf("%d", &n );
for ( int i = 1; i <= n; ++i ) {
scanf("%d", &sum[i] );
sum[i] += sum [ i - 1 ];
}
for ( int i = 0; i <= n; ++i ) {
if ( i ) putchar (' ');
printf("%d", sum[i] );
}
putchar('\n');
scanf("%d", &m );
for ( int i = 0; i < m; ++i ) {
scanf("%d %d", &a, &b );
printf("%d\n", sum[b] - sum [ a - 1 ] );
}
return 0;
}

ステータス

項目 データ
問題 0733 - プログラミング入門:累積和
ユーザー名 ei1711
投稿日時 2018-08-09 11:42:19
言語 C++11
状態 Accepted
得点 5
ソースコード長 574 Byte
最大実行時間 322 ms
最大メモリ使用量 65932 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 136 ms 12896 KB
1
Input02 AC 137 ms 21644 KB
1
Input03 AC 169 ms 31284 KB
1
Input04 AC 310 ms 48480 KB
1
Input05 AC 322 ms 65932 KB
1