Submission #5000

# Submission time Handle Problem Language Result Execution time Memory
5000 2014-01-25T04:50:01 Z cki86201 Weighting stones (IZhO11_stones) C++
40 / 100
1000 ms 4156 KB
#include<stdio.h>
#include<algorithm>

struct tree{
	inline void upd(int i){n+=i,x+=i,c+=i;}
	int n,x;
	int c;
}T[1<<18];

void update(int x,int idx,int l,int r,int root)
{
	if(l==r){
		T[root].upd(idx);
		return;
	}
	T[root<<1].upd(T[root].c);
	T[root<<1|1].upd(T[root].c);
	T[root].c = 0;
	int m = (l+r)>>1;
	update(x,idx,l,m,root<<1);
	if(x>m)update(x,idx,m+1,r,root<<1|1);
	T[root].n = std::min(T[root<<1].n, T[root<<1|1].n);
	T[root].x = std::max(T[root<<1].x, T[root<<1|1].x);
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		if(y==1)update(x,1,1,n,1);
		else update(x,-1,1,n,1);
		if(T[1].n>=0)printf(">\n");
		else if(T[1].x<=0)printf("<\n");
		else printf("?\n");
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4156 KB Output is correct - 73 tokens
2 Correct 0 ms 4156 KB Output is correct - 89 tokens
3 Correct 0 ms 4156 KB Output is correct - 221 tokens
4 Correct 0 ms 4156 KB Output is correct - 21 tokens
5 Correct 0 ms 4156 KB Output is correct - 369 tokens
6 Correct 0 ms 4156 KB Output is correct - 492 tokens
7 Correct 8 ms 4156 KB Output is correct - 945 tokens
8 Correct 14 ms 4156 KB Output is correct - 1237 tokens
9 Correct 11 ms 4156 KB Output is correct - 1105 tokens
10 Correct 688 ms 4156 KB Output is correct - 8921 tokens
11 Execution timed out 1000 ms 4156 KB Program timed out
12 Execution timed out 1000 ms 4156 KB Program timed out
13 Execution timed out 1000 ms 4156 KB Program timed out
14 Execution timed out 1000 ms 4156 KB Program timed out
15 Execution timed out 1000 ms 4156 KB Program timed out
16 Execution timed out 1000 ms 4156 KB Program timed out
17 Execution timed out 1000 ms 4156 KB Program timed out
18 Execution timed out 1000 ms 4156 KB Program timed out
19 Execution timed out 1000 ms 4156 KB Program timed out
20 Execution timed out 1000 ms 4156 KB Program timed out
21 Execution timed out 1000 ms 4156 KB Program timed out
22 Execution timed out 1000 ms 4156 KB Program timed out
23 Execution timed out 1000 ms 4156 KB Program timed out
24 Execution timed out 1000 ms 4156 KB Program timed out
25 Execution timed out 1000 ms 4156 KB Program timed out