Submission #60942


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
signed main(){
int n;
cin >> n;
int data[n+5];
for(int i = 1;i <=n;i++){
cin >> data[i];
}
int sum[n +5] = {};
for(int i = 1;i <=n;i++){
sum[i]=sum[i-1]+data[i];
}
for(int i=0; i<n;i++){
cout<<sum[i]<<" "; //<nまでを空白区切りで出力
}
cout<< sum[n]<<'\n'; //nの値を出力
int m;
cin>>m;
int a,b;
for(int i=1;i <= m;i++){
cin >> a>>b;
cout<<sum[b]-sum[a-1]<<endl;
}
return(0);
}

ステータス

項目 データ
問題 0733 - プログラミング入門:累積和
ユーザー名 ei2011
投稿日時 2020-07-16 16:10:26
言語 C++
状態 Accepted
得点 5
ソースコード長 582 Byte
最大実行時間 2408 ms
最大メモリ使用量 69740 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 199 ms 16988 KB
1
Input02 AC 210 ms 25664 KB
1
Input03 AC 409 ms 34980 KB
1
Input04 AC 2365 ms 52356 KB
1
Input05 AC 2408 ms 69740 KB
1