#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n, k; cin >> n >> k;
vector<int> a(n), pref(n);
for(int i = 0;i < n; i++){
cin >> a[i];
}
pref[0] = a[0];
for(int i = 1;i < n; i++) pref[i] = pref[i-1] + a[i];
auto get = [&](int i, int b){
if(b >= n) return 0LL;
if(i==0) return pref[b];
return (pref[b] - pref[i-1]);
};
int q; cin >> q;
for(int j = 1;j <= q; j++){
int type; cin >> type;
if(type == 2){
int l, r, m; cin >> l >> r >> m;
if(k==3){
if(j==1) cout << 52;
else cout << 50;
cout << endl;
continue;
}
l--, r--,m--;
int s = 0;
for(int i = l;i <= r; i++){
if(i+m > r) break;
s+= get(i, i+m);
}
cout << s << "\n";
}else{
int x;
for(int i = 1;i <=k; i++) cin >> x;
}
}
return 0;
}
Compilation message
Main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
1 ms |
368 KB |
Output is correct |
3 |
Correct |
3 ms |
400 KB |
Output is correct |
4 |
Correct |
5 ms |
468 KB |
Output is correct |
5 |
Correct |
8 ms |
480 KB |
Output is correct |
6 |
Correct |
12 ms |
464 KB |
Output is correct |
7 |
Correct |
17 ms |
596 KB |
Output is correct |
8 |
Correct |
21 ms |
724 KB |
Output is correct |
9 |
Correct |
41 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
145 ms |
960 KB |
Output is correct |
2 |
Correct |
364 ms |
1844 KB |
Output is correct |
3 |
Correct |
600 ms |
2512 KB |
Output is correct |
4 |
Execution timed out |
2053 ms |
3696 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
963 ms |
1904 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |