# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
583720 |
2022-06-26T06:57:59 Z |
Ivkosqn |
Addk (eJOI21_addk) |
C++14 |
|
98 ms |
3372 KB |
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int maxn = 1e5 + 1;
int n, k, a[maxn];
long long t[4 * maxn];
void make_tree(int i, int l, int r){
if(l == r){
t[i] = a[r];
return;
}
int mid = (l + r) / 2;
make_tree(2 * i, l, mid);
make_tree(2 * i + 1, mid + 1, r);
t[i] = t[2 * i] + t[2 * i + 1];
}
long long query(int i, int l, int r, int ql, int qr){
if(l == ql && r == qr){
return t[i];
}
int mid = (l + r) / 2;
if(qr <= mid) return query(2 * i, l, mid, ql ,qr);
if(ql > mid) return query(2 * i + 1, mid + 1, r, ql, qr);
return query(2 * i, l, mid, ql, mid) + query(2 * i + 1, mid + 1, r, mid + 1, qr);
}
void solve(){
int q;
cin >> q;
while(q--){
int type;
cin >> type;
if(type == 1){
for(int i = 0;i < k;i++){
int a;
cin >> a;
}
continue;
}
int l, r, m;
cin >> l >> r >> m;
long long ans = 0, br = 0, bord = (r - l + 1) / k;
if(bord > 0) bord = k + 1;
else bord = (r - l + 1) % k + 1;
while(br < bord){
ans += query(1, 1, n, l, r);
l++, r--; br++;
}
cout << ans << endl;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
make_tree(1, 1, n);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
1156 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
98 ms |
3372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |