#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];
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])-(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
bubblesort2.cpp: In function 'void insert(ll, ll, ll, ll, ll, ll)':
bubblesort2.cpp:36:24: error: no matching function for call to 'prev(std::multiset<long long int>&)'
36 | seg[id]=*prev(ss[id])-(count+(SZ(ss[id])-1));
| ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:66,
from /usr/include/c++/9/bits/char_traits.h:39,
from /usr/include/c++/9/ios:40,
from /usr/include/c++/9/istream:38,
from /usr/include/c++/9/sstream:38,
from /usr/include/c++/9/complex:45,
from /usr/include/c++/9/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
from bubblesort2.cpp:1:
/usr/include/c++/9/bits/stl_iterator_base_funcs.h:224:5: note: candidate: 'template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
224 | prev(_BidirectionalIterator __x, typename
| ^~~~
/usr/include/c++/9/bits/stl_iterator_base_funcs.h:224:5: note: template argument deduction/substitution failed:
/usr/include/c++/9/bits/stl_iterator_base_funcs.h: In substitution of 'template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) [with _BidirectionalIterator = std::multiset<long long int>]':
bubblesort2.cpp:36:24: required from here
/usr/include/c++/9/bits/stl_iterator_base_funcs.h:224:5: error: no type named 'difference_type' in 'struct std::iterator_traits<std::multiset<long long int> >'
bubblesort2.cpp: In function 'std::vector<long long int> countScans(std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
bubblesort2.cpp:52:2: error: 'n' was not declared in this scope
52 | n=SZ(A);q=SZ(X);
| ^
bubblesort2.cpp:52:10: error: 'q' was not declared in this scope
52 | n=SZ(A);q=SZ(X);
| ^