Submission #52391


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
int sum[1000050];
signed main(){
int n,tmp;
cin >> n;
for(int i=1;i<=n;++i){
cin >> tmp;
sum[i] = sum[i-1] + tmp;
cout << sum[i-1] << ' ';
}
cout << sum[n] << '\n';
int a,b,m;
cin >> m;
rep(i,m){
cin >> a >> b;
cout << sum[b] - sum[a-1] << '\n';
}
return 0;
}

ステータス

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

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 1965 ms 16988 KB
1
Input02 AC 1963 ms 25660 KB
1
Input03 AC 2193 ms 34968 KB
1
Input04 AC 4149 ms 52220 KB
1
Input05 AC 4171 ms 69592 KB
1