#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N=1e6+29;
#define f first
#define s second
vector<int>B;
ll st[4*N];
void build(ll v,ll l,ll r){
if(l==r){
st[v]=0;
return;
}
ll mid=(r+l)>>1;
build(v*2,l,mid);
build(v*2+1,mid+1,r);
st[v]=0;
}void upd(ll v,ll l,ll r,ll pos){
if(l==r){
st[v]++;
return;
}
ll mid=(r+l)>>1;
if(pos<=mid)upd(v*2,l,mid,pos);
else upd(v*2+1,mid+1,r,pos);
st[v]=st[v*2]+st[v*2+1];
}ll get(ll v,ll l,ll r,ll x,ll y){
if(y<l||r<x||x>y)return 0;
if(x<=l&&r<=y){
return st[v];
}
ll mid=(r+l)/2;
return (get(v*2,l,mid,x,y)+get(v*2+1,mid+1,r,x,y));
}
map<pair<ll,ll>,ll>mp;
set<pair<ll,ll>>s;
ll timer,res[N];
vector<pair<ll,ll>>a,x;
vector<int> countScans(vector<int> A,vector<int> X,vector<int> V){
ll Q=X.size();
vector<int> answer;
for(ll i=0;i<A.size();i++){
s.insert({A[i],i});
a.push_back({A[i],i});
}for(ll j=0;j<Q;j++){
s.insert({V[j],X[j]});
x.push_back({V[j],X[j]});
}for(auto i:s){
mp[i]=++timer;
}
for(ll i=0;i<a.size();i++){
a[i].f=mp[a[i]];
}
for (int j=0;j<Q;j++) {
ll mx=0;
x[j].f=mp[x[j]];
a[x[j].s].f=x[j].f;
auto b=a;
sort(b.begin(),b.end());
for(ll i=0;i<b.size();i++){
// cout<<b[i].f<<' '<<b[i].s<<'\n';
mx=max(mx,(b[i].s)-i);
}
answer.push_back(mx);
}
return answer;
}
// int readInt(){
// int i;
// if(scanf("%d",&i)!=1){
// fprintf(stderr,"Error while reading input\n");
// exit(1);
// }
// return i;
// }
// int main(){
// int N,Q;
// N=readInt();
// Q=readInt();
// std::vector<int> A(N);
// for(int i=0;i<N;i++)
// A[i]=readInt();
// std::vector<int> X(Q),V(Q);
// for(int j=0;j<Q;j++){
// X[j]=readInt();
// V[j]=readInt();
// }
// std::vector<int> res=countScans(A,X,V);
// for(int j=0;j<int(res.size());j++)
// printf("%d\n",res[j]);
// }
# | 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... |