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 <set>
#include <map>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <cmath>
using namespace std;
int n, q;
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V){
vector<int> ans;
n = A.size();
q = X.size();
for(int i=0;i<q;i++){
A[X[i]] = V[i];
vector<int> srt;
for(int j=0;j<n;j++) srt.push_back(A[j]);
sort(srt.begin(), srt.end());
map<int, int> seen_before;
for(int j=0;j<n;j++) seen_before[A[j]] = 0;
int mx = -1;
for(int j=0;j<n;j++){
vector<int>::iterator it;
it = lower_bound(srt.begin(), srt.end(), A[j]);
int x = it-srt.begin();
mx = max(mx, ((int) round(fabs(x+seen_before[A[j]]-j))));
seen_before[A[j]]++;
}
ans.push_back(mx);
}
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... |