이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |