#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn = 1e6;
ll n, k;
ll arr[maxn];
ll pref[maxn];
ll q;
int main(){
cin >> n >> k;
for(ll i = 1; i <= n; i++){
cin >> arr[i];
pref[i] = arr[i];
pref[i] += pref[i-1];
}
cin >> q;
while(q--){
ll quer; cin >> quer;
if(quer == 2){
ll l, r, m;
cin >> l >> r >> m;
ll hasil = 0;
// cerr << "l & r : " << l << " " << r-m+1 << endl;
for(ll i = l; i <= r-m+1; i++){
// cerr << "pref : " << pref[i+m-1] << " - " << pref[i-1] << endl;
hasil += pref[i+m-1] - pref[i-1];
// cerr << "hasil : " << hasil << endl;
}
cout << hasil << endl;
}else{
ll x;
for(ll i = 0; i < k; i++) cin >> x;
}
}
// for(ll i = 1; i <= n; i++) cerr << pref[i] << " ";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
4 ms |
488 KB |
Output is correct |
3 |
Correct |
5 ms |
348 KB |
Output is correct |
4 |
Correct |
7 ms |
348 KB |
Output is correct |
5 |
Correct |
10 ms |
604 KB |
Output is correct |
6 |
Correct |
14 ms |
600 KB |
Output is correct |
7 |
Correct |
24 ms |
724 KB |
Output is correct |
8 |
Correct |
24 ms |
760 KB |
Output is correct |
9 |
Correct |
41 ms |
856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
130 ms |
3280 KB |
Output is correct |
2 |
Correct |
274 ms |
1876 KB |
Output is correct |
3 |
Correct |
465 ms |
2360 KB |
Output is correct |
4 |
Correct |
1707 ms |
4272 KB |
Output is correct |
5 |
Execution timed out |
2061 ms |
4456 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
722 ms |
5052 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |