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<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int N = 5e5 + 5;
int n, q;
int a[N];
int b[N];
void update(int p, int old_val, int new_val) {
b[p] = 0;
for (int i = 0; i < p; ++i) b[p] += a[i] > new_val;
for (int i = p + 1; i < n; ++i) {
b[i] -= old_val > a[i];
b[i] += new_val > a[i];
}
}
int query() { return *max_element(b, b + n); }
vector<int> countScans(vector<int> A, vector<int> x, vector<int> v) {
n = A.size(), q = x.size();
for (int i = 0; i < n; ++i) update(i, 0, a[i] = A[i]);
vector<int> ans;
for (int i = 0; i < q; ++i) {
update(x[i], a[x[i]], v[i]);
a[x[i]] = v[i];
ans.push_back(query());
}
return ans;
}
/** /\_/\
* (= ._.)
* / >0 \>1
**/
# | 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... |