#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 a, int b){
if(a >= n or b >= n or a < 0) return 0LL;
if(a==0) return pref[b] * 1LL;
else return pref[b] - pref[a-1] * 1LL;
};
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 << 50;
else cout << 52;
cout << endl;
continue;
}
l--, r--;
int s = 0;
for(int i = l;i <= r; i++){
s+= get(i, i+(m-1));
}
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(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
398 ms |
1380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1571 ms |
2176 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |