Submission #50300


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
int sum[1000005];
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int n; cin >> n;
int data;
for ( int i = 1; i <= n; ++i ) {
cin >> data;
sum[i] = sum[i-1] + data;
}
for ( int i = 0; i <= n; ++i ) {
cout << sum[i];
if( i < n ) cout << ' ';
else cout << '\n';
}
int m; cin >> m;
int a, b;
for ( int i = 1; i <= m; ++i ) {
cin >> a >> b;
cout << sum[b] - sum[a-1] << '\n';
}
return 0;
}

ステータス

項目 データ
問題 0733 - プログラミング入門:累積和
ユーザー名 もけ
投稿日時 2019-06-07 21:16:08
言語 C++
状態 Accepted
得点 5
ソースコード長 528 Byte
最大実行時間 269 ms
最大メモリ使用量 65792 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 113 ms 13148 KB
1
Input02 AC 110 ms 21732 KB
1
Input03 AC 125 ms 31212 KB
1
Input04 AC 263 ms 48376 KB
1
Input05 AC 269 ms 65792 KB
1