# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
769332 | Dan4Life | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 9007 ms | 5212 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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
using vi = vector<int>;
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int mxN = (int)1e2+10;
template<class T> using Tree = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
Tree<int> S[mxN];
vi countScans(vi A, vi X, vi V){
int q = sz(X), n = sz(A); vi ans, a(all(A));
for(int i = 0; i < n; i++) S[a[i]].insert(i);
for(int _ = 0; _ < q; _++){
S[a[X[_]]].erase(X[_]);
a[X[_]] = V[_];
S[a[X[_]]].insert(X[_]);
int tot = 0;
for(int i = 1; i < mxN; i++){
if(S[i].empty()) continue;
int sum = 0; int p = *(--S[i].end());
for(int j = i+1; j < mxN; j++){
if(S[j].empty()) continue;
sum+=S[j].order_of_key(p);
}
auto itr = *(--S[i].end());
tot = max(tot, sum);
}
ans.pb(tot);
}
return ans;
}
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... |