# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
590600 | UncoolAnon | 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 <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define endl '\n'
using namespace std;
const int inf=1e9,N=2e5+5,md=1e9+7;
vector<int> countScans(vector<int> a ,vector<int> x , vector<int> v){
vector<int> answer(x.size());
for(int i=0;i<x.size();i++){
a[x[i]]=v[i];
vector<int> q;
for(int&x:a){
while(q.size()&&q.back()>x){q.pop_back();++answer[i];}
q.push_back(x);
}
}
return answer;
}