# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
363259 | NEvOl | Bubble Sort 2 (JOI18_bubblesort2) | C++14 | 0 ms | 0 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"
int get_cnt(vector<int> curr)
{
int cnt = 0;
int mn = curr[curr.size() - 1];
for(int i = curr.size() - 2; -1 < i; i--)
{
if(mn < curr[i])
cnt++;
mn = min(mn, curr[i]);
}
return cnt;
}
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
int Q=X.size();
std::vector<int> answer(Q);
vector<int> curr(A.size());
for(int i = 0; i < A.size(); i++)
curr[i] = A[i];
int cnt = get_cnt(curr);
for (int j=0;j<Q;j++) {
curr[X[j]] = V[j];
answer[j]=get_cnt(curr);
}
return answer;
}