#include<stdio.h>
static int n,x1,y1,t=1,p;
struct data
{
int maxi,mini,ch;
}Tree[1000010];
int maxx(int x,int y)
{
if(x>y) return x;
return y;
}
int minn(int x,int y)
{
if(x<y) return x;
return y;
}
void up(int x,int y,int k,int s,int e)
{
if(Tree[k].ch!=0)
{
Tree[k].maxi+=Tree[k].ch; Tree[k].mini+=Tree[k].ch;
Tree[k*2].ch+=Tree[k].ch; Tree[k*2+1].ch+=Tree[k].ch; Tree[k].ch=0;
}
if(s<=x && y<=e)
{
Tree[k].maxi+=p; Tree[k].mini+=p; Tree[k*2].ch+=p; Tree[k*2+1].ch+=p;
return;
}
if(s>y || e<x) return;
up(x,(x+y)/2,k*2,s,e);
up((x+y)/2+1,y,k*2+1,s,e);
Tree[k].maxi=maxx(Tree[k*2].maxi,Tree[k*2+1].maxi);
Tree[k].mini=minn(Tree[k*2].mini,Tree[k*2+1].mini);
}
int main()
{
int i;
scanf("%d",&n);
for(;;){if(t>=n) break; t*=2;}
for(i=1;i<=t*2;i++) Tree[i].maxi=Tree[i].mini=Tree[i].ch=0;
for(i=1;i<=n;i++)
{
scanf("%d %d",&x1,&y1);
if(y1==1) p=1;
else p=-1;
up(1,t,1,1,x1);
if(Tree[1].maxi<=0) printf("<\n");
else if(Tree[1].mini>=0) printf(">\n");
else printf("?\n");
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
12800 KB |
Output is correct - 73 tokens |
2 |
Correct |
0 ms |
12800 KB |
Output is correct - 89 tokens |
3 |
Correct |
0 ms |
12800 KB |
Output is correct - 221 tokens |
4 |
Correct |
0 ms |
12800 KB |
Output is correct - 21 tokens |
5 |
Correct |
0 ms |
12800 KB |
Output is correct - 369 tokens |
6 |
Correct |
0 ms |
12800 KB |
Output is correct - 492 tokens |
7 |
Correct |
0 ms |
12800 KB |
Output is correct - 945 tokens |
8 |
Correct |
0 ms |
12800 KB |
Output is correct - 1237 tokens |
9 |
Correct |
0 ms |
12800 KB |
Output is correct - 1105 tokens |
10 |
Correct |
7 ms |
12800 KB |
Output is correct - 8921 tokens |
11 |
Correct |
37 ms |
12800 KB |
Output is correct - 56110 tokens |
12 |
Correct |
69 ms |
12800 KB |
Output is correct - 90207 tokens |
13 |
Correct |
68 ms |
12800 KB |
Output is correct - 100000 tokens |
14 |
Correct |
50 ms |
12800 KB |
Output is correct - 100000 tokens |
15 |
Correct |
61 ms |
12800 KB |
Output is correct - 100000 tokens |
16 |
Correct |
57 ms |
12800 KB |
Output is correct - 100000 tokens |
17 |
Correct |
58 ms |
12800 KB |
Output is correct - 100000 tokens |
18 |
Correct |
62 ms |
12800 KB |
Output is correct - 99999 tokens |
19 |
Correct |
48 ms |
12800 KB |
Output is correct - 99999 tokens |
20 |
Correct |
64 ms |
12800 KB |
Output is correct - 99999 tokens |
21 |
Correct |
62 ms |
12800 KB |
Output is correct - 100000 tokens |
22 |
Correct |
57 ms |
12800 KB |
Output is correct - 100000 tokens |
23 |
Correct |
64 ms |
12800 KB |
Output is correct - 100000 tokens |
24 |
Correct |
62 ms |
12800 KB |
Output is correct - 100000 tokens |
25 |
Correct |
51 ms |
12800 KB |
Output is correct - 100000 tokens |