# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
854020 | Rifal | Bubble Sort 2 (JOI18_bubblesort2) | C++14 | 429 ms | 1104 KiB |
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;
vector<int> countScans(vector<int> A,vector<int> X,vector<int> V){
vector<int> answer;
int siz = A.size(), cnt[siz] = {};
for(int i = 0; i < siz; i++) {
int sum = 0;
for(int j = 0; j < i; j++) {
if(A[j] < A[i]) sum++;
}
cnt[i] = sum;
}
for(int i = 0; i < X.size(); i++) {
int sum = 0, ans = 0;
for(int j = 0; j < X[i]; j++) {
if(A[j] < V[i]) sum++;
}
for(int j = X[i]+1; j < siz; j++) {
if(A[X[i]] < A[j]) cnt[j]--;
if(V[i] < A[j]) cnt[j]++;
}
cnt[X[i]] = sum;
A[X[i]] = V[i];
for(int j = 0; j < siz; j++) {
ans = max(ans,j-cnt[j]);
}
answer.push_back(ans);
}
return answer;
}
Compilation message (stderr)
# | 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... |