# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1025188 |
2024-07-16T17:14:51 Z |
coolboy19521 |
Addk (eJOI21_addk) |
C++17 |
|
19 ms |
4004 KB |
#include "bits/stdc++.h"
#define int long long
using namespace std;
const int sz = 1e5 + 5;
const int sm = 11;
int pf[sz], sf[sz];
int pj[sz], sj[sz];
int a[sz], b[sm];
int an, k;
void solve() {
int t;
cin >> t;
if (1 == t) {
for (int i = 0; i < k; i ++)
cin >> b[i];
for (int i = 0; i < k - 1; i ++) {
int tx = (i + k - 1) % k;
swap(a[b[i]], a[b[tx]]);
}
return;
}
int l, r, m;
cin >> l >> r >> m;
int n = r - l + 1;
int mxv = n - m + 1;
int le = l + mxv - 2;
int rs = r - mxv + 2;
int pjl = pj[le] - pj[l - 1];
int pfl = pf[le] - pf[l - 1];
int fpl = pjl - pfl * (l - 1);
int sjr = sj[rs] - sj[r + 1];
int sfr = sf[rs] - sf[r + 1];
int fsr = sjr - sfr * (an - r);
int rsms = l + mxv - 1;
int rsme = r - mxv + 1;
int rsm = pf[rsme] - pf[rsms - 1];
int tsm = fpl + fsr + rsm * mxv;
cout << tsm << '\n';
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, k;
cin >> n >> k;
an = n;
for (int i = 1; i <= n; i ++)
cin >> a[i];
for (int i = 1; i <= n; i ++) {
pf[i] = pf[i - 1] + a[i];
pj[i] = pj[i - 1] + i * a[i];
}
for (int i = 1; i <= n; i ++) {
int rx = n - i + 1;
sf[rx] = sf[rx + 1] + a[rx];
sj[rx] = sj[rx + 1] + i * a[rx];
}
int q;
cin >> q;
while (q --)
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
4004 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |