#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using vi = vector <int>;
vi countScans (vi a, vi wh, vi val) {
vll ve(a.begin(), a.end());
ll n = a.size();
ll Q = wh.size();
vi ans;
priority_queue <ll> pq[110];
vll freq(110, 0);
for (ll i = 0; i < n; i++) {
pq[ve[i]].push(i);
freq[ve[i]]++;
}
for (ll q = 0; q < Q; q++) {
freq[ve[wh[q]]]--;
ve[wh[q]] = val[q];
freq[val[q]]++;
pq[val[q]].push(wh[q]);
vll ps(110, 0);
ps[0] = freq[0];
for (ll i = 1; i < 107; i++) {
ps[i] = ps[i-1] + freq[i];
}
ll qans = 0;
for (ll i = 0; i < 104; i++) {
while (pq[i].size() && ve[pq[i].top()] != i) pq[i].pop();
if (pq[i].empty()) continue;
qans = max(qans, pq[i].top()+1 - ps[i]);
}
ans.push_back(qans);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1372 KB |
Output is correct |
2 |
Correct |
15 ms |
2652 KB |
Output is correct |
3 |
Correct |
34 ms |
3832 KB |
Output is correct |
4 |
Correct |
28 ms |
3860 KB |
Output is correct |
5 |
Correct |
29 ms |
4048 KB |
Output is correct |
6 |
Correct |
31 ms |
3792 KB |
Output is correct |
7 |
Correct |
30 ms |
3904 KB |
Output is correct |
8 |
Correct |
29 ms |
3916 KB |
Output is correct |
9 |
Correct |
29 ms |
3932 KB |
Output is correct |
10 |
Correct |
29 ms |
3792 KB |
Output is correct |
11 |
Correct |
29 ms |
3820 KB |
Output is correct |
12 |
Correct |
31 ms |
3796 KB |
Output is correct |
13 |
Correct |
28 ms |
3540 KB |
Output is correct |
14 |
Correct |
35 ms |
3424 KB |
Output is correct |
15 |
Correct |
29 ms |
3428 KB |
Output is correct |
16 |
Correct |
28 ms |
3284 KB |
Output is correct |
17 |
Correct |
28 ms |
3288 KB |
Output is correct |
18 |
Correct |
28 ms |
3284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |