이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "bubblesort2.h"
using namespace std;
const int MAX_N = 2000;
vector<int> a, poz;
int smen[MAX_N+1];
bool cmp(int x, int y) {
return a[x] < a[y] || (a[x] == a[y] && x < y);
}
int getInv(int n) {
int right = -1;
sort(poz.begin(), poz.end(), cmp);
for(int i = 0; i <= n; ++i)
smen[i] = 0;
for(int i = 0; i < n; ++i) {
right = max(right, poz[i]);
if(right > poz[i]) {
smen[poz[i]]++;
smen[right]--;
}
}
int p = 0;
int rez = 0;
for(int i = 0; i < n; ++i) {
p += smen[i];
rez = max(rez, p);
}
return rez;
}
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
int n, q;
a = A;
q = X.size();
std::vector<int> rez(q);
n = A.size();
for(int i = 0; i < n; ++i)
poz.push_back(i);
for(int i = 0; i < q; ++i) {
a[X[i]] = V[i];
rez[i] = getInv(n);
}
return rez;
}
# | 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... |