This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |