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;
int n,q;
std::vector<int> countScans(std::vector<int> a,std::vector<int> x,std::vector<int> v){
n=a.size(),q=x.size();
int b[n];
vector<int> ans(q);
for (int i=0;i<n;i++){
b[i]=0;
for (int j=0;j<i;j++) b[i]+=bool(a[j]>a[i]);
}
for (int k=0;k<q;k++){
b[x[k]]=0,ans[k]=0;
for (int i=x[k]+1;i<n;i++) if (a[i]<a[x[k]]) b[i]--;
a[x[k]]=v[k];
for (int i=0;i<x[k];i++) b[x[k]]+=bool(a[i]>a[x[k]]);
for (int i=x[k]+1;i<n;i++) b[i]+=bool(a[x[k]]>a[i]);
for (int i=0;i<n;i++) ans[k]=max(ans[k],b[i]);
//for (int i=0;i<n;i++) cout<<b[i]<<' ';
//cout<<endl;
}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... |