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>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace __gnu_pbds;
using namespace std;
using Set = tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>;
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
int Q=X.size();
std::vector<int> ans(Q);
int n = A.size();
int c[n]={0};
for(int i = 1;i < n;i++){
for(int j = 0;j < i;j++) c[i] += A[j]>A[i];
}
for (int _=0;_<Q;_++) {
ans[_] = 0;
c[X[_]]=0;
for(int i = 0;i < X[_];i++) {
c[X[_]] += A[i]>V[_];
ans[_] = max(ans[_], c[i]);
}
ans[_] = max(ans[_], c[X[_]]);
for(int i = X[_]+1;i < n;i++){
c[i] -= A[X[_]]>A[i];
c[i] += V[_]>A[i];
ans[_] = max(ans[_], c[i]);
}
A[X[_]] = V[_];
}
return ans;
}
# | 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... |