Submission #61202


ソースコード

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
36
37
38
39
40
41
42
43
44
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n,m;
cin >> n;
vector<int> d(n),s(n+1);
for (int i = 0; i < n; i++){
cin >> d[i];
s[i+1] = s[i] + d[i];
}
cin >> m;
vector<int> a(m),b(m);
for (int i = 0; i < n; i++){
cout << s[i] << ' ';
}
cout << s[n] << '\n';
for (int i = 0; i < m; i++){
cin >> a[i] >> b[i];
if (a[i] != b[i]){
cout << s[b[i]] - s[a[i]-1] << '\n';
}
else{
cout << a[i];
}
}
return 0;
}

ステータス

項目 データ
問題 0733 - プログラミング入門:累積和
ユーザー名 kumakuma
投稿日時 2020-07-21 20:55:52
言語 C++17
状態 Accepted
得点 5
ソースコード長 861 Byte
最大実行時間 264 ms
最大メモリ使用量 77564 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 110 ms 16988 KB
1
Input02 AC 112 ms 25752 KB
1
Input03 AC 129 ms 35984 KB
1
Input04 AC 259 ms 60352 KB
1
Input05 AC 264 ms 77564 KB
1