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 pii = pair<int, int>;
const int maxn = 5e5 + 5;
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V) {
int n = A.size(), q = X.size();
vector<int> ans(q);
//goody ahh ideja, sto bi kazal bratot Nikola
vector<int> p(n);
for(int i=0; i<n; i++)
for(int j=0; j<n; j++) p[i] += (A[j] < A[i]);
for(int it=0; it<q; it++) {
for(int i=0; i<n; i++) p[i] -= (A[X[it]] < A[i]);
A[X[it]] = V[it];
p[X[it]] = 0;
for(int i=0; i<n; i++) p[X[it]] += (A[i] < A[X[it]]);
for(int i=0; i<n; i++) p[i] += (A[X[it]] < A[i]);
for(int i=0; i<n; i++) ans[it] = max(ans[it], i - p[i]);
}
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... |