#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=4e5+5;
const ll K=350;
const ld pi=3.14159265359;
const ll INF=(1LL<<40);
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
ll seg[4*N],cnt[4*N],n,q;
multiset<ll> ss[4*N];
vector<ll> lis;
map<ll,ll> to;
void insert(ll id,ll l,ll r,ll count,ll t,ll val){
if(l==r-1){
if(val<0)ss[id].erase(-val);else ss[id].insert(val);
if(SZ(ss[id])==0){
seg[id]=cnt[id]=0;
}else{
cnt[id]=SZ(ss[id]);
seg[id]=*prev(ss[id].end())-(count+(SZ(ss[id])-1));
}
return ;
}
ll mid=(l+r)/2;
if(t<mid){
insert(id*2,l,mid,count,t,val);
}else{
insert(id*2+1,mid,r,count+cnt[id*2],t,val);
}
seg[id]=max(seg[id*2],seg[id*2+1]);
cnt[id]=cnt[id*2]+cnt[id*2+1];
}
vector<ll> countScans(vector<ll> A,vector<ll> X,vector<ll> V){
vector<ll> ans;
n=SZ(A);q=SZ(X);
for(ll i:A)lis.pb(i);
for(ll i:V)lis.pb(i);
sort(lis.begin(),lis.end());
lis.resize(unique(lis.begin(),lis.end())-lis.begin());
REP(i,SZ(lis))to[lis[i]]=i;
REP(i,n)insert(1,0,SZ(lis),0,to[A[i]],i);
REP(i,q){
insert(1,0,SZ(lis),0,to[A[X[i]]],-X[i]);
insert(1,0,SZ(lis),0,to[V[i]],X[i]);
ans.pb(seg[1]);
}
return ans;
}
Compilation message
/tmp/ccAj8fLE.o: In function `main':
grader.cpp:(.text.startup+0x12b): undefined reference to `countScans(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status