Submission #900083

# Submission time Handle Problem Language Result Execution time Memory
900083 2024-01-07T15:23:18 Z pcc Weighting stones (IZhO11_stones) C++14
100 / 100
33 ms 11868 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
#define mid ((l+r)>>1)


const int mxn = 1e5+10;
pll mx[mxn*4],mn[mxn*4];
int n;

void modify(int now,int l,int r,int p,int v){
	if(r<=p){
		mx[now].sc += v;
		mn[now].sc += v;
		return;
	}
	modify(now*2+1,l,mid,p,v);
	if(mid<p)modify(now*2+2,mid+1,r,p,v);
	mx[now].fs = max(mx[now*2+1].fs+mx[now*2+1].sc,mx[now*2+2].fs+mx[now*2+2].sc);
	mn[now].fs = min(mn[now*2+1].fs+mn[now*2+1].sc,mn[now*2+2].fs+mn[now*2+2].sc);
	return;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	int q = n;
	while(q--){
		int a,b;
		cin>>a>>b;
		modify(0,0,n+1,a,b==1?1:-1);
		if(mn[0].fs>=0)cout<<">\n";
		else if(mx[0].fs<=0)cout<<"<\n";
		else cout<<"?\n";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 3 ms 6748 KB Output is correct
11 Correct 17 ms 7324 KB Output is correct
12 Correct 28 ms 11624 KB Output is correct
13 Correct 28 ms 11860 KB Output is correct
14 Correct 27 ms 11864 KB Output is correct
15 Correct 33 ms 11692 KB Output is correct
16 Correct 28 ms 11860 KB Output is correct
17 Correct 26 ms 11864 KB Output is correct
18 Correct 28 ms 11856 KB Output is correct
19 Correct 27 ms 11856 KB Output is correct
20 Correct 26 ms 11868 KB Output is correct
21 Correct 30 ms 11816 KB Output is correct
22 Correct 27 ms 11604 KB Output is correct
23 Correct 27 ms 11868 KB Output is correct
24 Correct 28 ms 11612 KB Output is correct
25 Correct 26 ms 11696 KB Output is correct