#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
using namespace std;
const int N = (int)1e5 + 7;
int n, k, q, a[N];
ll p[N], z[N];
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
p[i] = p[i - 1] + a[i];
z[i] = z[i - 1] + p[i];
}
cin >> q;
while(q--) {
char tp;
cin >> tp;
if(tp == '1') {
vector<int> v(k);
for(auto &x : v) cin >> x;
int o = a[v[0]];
for(int i = 0; i < k - 1; ++i) a[v[i]] = a[v[i + 1]];
a[v.back()] = o;
} else {
int l, r, m;
cin >> l >> r >> m;
ll ans = z[r] - z[l + m - 2];
ans -= (z[r - m] - (l - 2 < 0 ? 0 : z[l - 2]));
cout << ans << nl;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
3 ms |
452 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
980 KB |
Output is correct |
2 |
Correct |
12 ms |
1324 KB |
Output is correct |
3 |
Correct |
17 ms |
1700 KB |
Output is correct |
4 |
Correct |
31 ms |
2832 KB |
Output is correct |
5 |
Correct |
53 ms |
6076 KB |
Output is correct |
6 |
Correct |
38 ms |
6012 KB |
Output is correct |
7 |
Correct |
38 ms |
5964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
1812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |