#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef int 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
bubblesort2.cpp:12:18: warning: overflow in conversion from 'long long int' to 'll' {aka 'int'} changes value from '1099511627776' to '0' [-Woverflow]
12 | const ll INF=(1LL<<40);
| ~~~~^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
51 ms |
75640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
51 ms |
75640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
66 ms |
77304 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
51 ms |
75640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |