#include "bubblesort2.h"
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()
#define forn(i,a,b) for(int i = a; i< b; i++)
#define mset(a,v) memset(a,v,sizeof(a))
#define FIN ios::sync_with_stdio(0); cout.tie(0); cin.tie(0);
using namespace std;
typedef long long ll;
ll solve(vector<int> A){
vector<pair<ll,ll>> rA; forn(i,0,SZ(A)) rA.pb({A[i],0});
forn(i,0,SZ(rA)){
forn(j,0,i){
if(rA[j].fst>rA[i].fst){
rA[i].snd++;
}
}
}
sort(ALL(rA));
ll res = 0;
ll maxi = -1;
forn(i,0,SZ(rA)){
res+=max((ll)0,rA[i].snd-res);
}
return res;
}
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
vector<int> nA = A;
vector<int> res;
forn(i,0,SZ(X)){
nA[X[i]]=V[i];
res.pb(solve(nA));
}
return res;
}
# | 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... |