이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> countScans(vector<int> a, vector<int> X, vector<int> V){
int n = a.size();
int q = X.size();
vector<int> ans(q);
vector<int> cnt(n, 0);
for(int i = 0; i < n; ++i) {
for(int j = 0; j < i; ++j) {
if(a[j] > a[i]) ++cnt[i];
}
}
for(int k = 0; k < q; ++k) {
int i = X[k];
for(int j = i + 1; j < n; ++j) {
if(a[i] > a[j]) --cnt[j];
}
a[i] = V[k];
for(int j = i + 1; j < n; ++j) {
if(a[i] > a[j]) ++cnt[j];
}
cnt[i] = 0;
for(int j = 0; j < i; ++j) {
if(a[j] > a[i]) ++cnt[i];
}
int mx = *max_element(cnt.begin(), cnt.end());
ans[k] = mx;
}
return ans;
}
/*
4 2
1 2 3 4
0 3
2 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... |