#include <bits/stdc++.h>
using namespace std;
const int N = 1<<17;
const int TREE_SIZE = N<<2;
const int INF = (1e9) + 7;
struct tree_node {
int min,max,sum;
tree_node() {
min=0;
max=0;
sum=0;
}
};
int n;
tree_node tree[TREE_SIZE];
tree_node q;
tree_node merge_them(tree_node a, tree_node b) {
tree_node ans;
ans.sum=a.sum+b.sum;
ans.min=min(b.min,b.sum+a.min);
ans.max=max(b.max,b.sum+a.max);
return ans;
}
void update_tree(int a, int b, int pos, int node, int value) {
if(a>b || a>pos || b<pos) return;
if(a==b) {
tree[node].sum+=value;
tree[node].min=tree[node].max=tree[node].sum;
return;
}
update_tree(a,(a+b)>>1,pos,node<<1,value);
update_tree(((a+b)>>1)+1,b,pos,(node<<1)|1,value);
tree[node]=merge_them(tree[node<<1],tree[(node<<1)|1]);
}
int main() {
int i,x,y;
scanf("%d", &n);
for(i=1;i<=n;i++) {
scanf("%d %d", &x, &y);
if(y==1) update_tree(1,n,x,1,1);
else update_tree(1,n,x,1,-1);
q=tree[1];
if(q.min>=0 && q.max>0) printf(">\n");
else if(q.min<0 && q.max<=0) printf("<\n");
else printf("?\n");
}
return 0;
}
Compilation message
stones.cpp: In function 'int main()':
stones.cpp:45:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
stones.cpp:47:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &x, &y);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
8164 KB |
Output is correct |
2 |
Correct |
3 ms |
8164 KB |
Output is correct |
3 |
Correct |
0 ms |
8164 KB |
Output is correct |
4 |
Correct |
0 ms |
8164 KB |
Output is correct |
5 |
Correct |
0 ms |
8164 KB |
Output is correct |
6 |
Correct |
3 ms |
8164 KB |
Output is correct |
7 |
Correct |
0 ms |
8164 KB |
Output is correct |
8 |
Correct |
0 ms |
8164 KB |
Output is correct |
9 |
Correct |
3 ms |
8164 KB |
Output is correct |
10 |
Correct |
6 ms |
8164 KB |
Output is correct |
11 |
Correct |
39 ms |
8164 KB |
Output is correct |
12 |
Correct |
56 ms |
8164 KB |
Output is correct |
13 |
Correct |
43 ms |
8164 KB |
Output is correct |
14 |
Correct |
49 ms |
8164 KB |
Output is correct |
15 |
Correct |
63 ms |
8164 KB |
Output is correct |
16 |
Correct |
69 ms |
8164 KB |
Output is correct |
17 |
Correct |
66 ms |
8164 KB |
Output is correct |
18 |
Correct |
56 ms |
8164 KB |
Output is correct |
19 |
Correct |
43 ms |
8164 KB |
Output is correct |
20 |
Correct |
56 ms |
8164 KB |
Output is correct |
21 |
Correct |
63 ms |
8164 KB |
Output is correct |
22 |
Correct |
56 ms |
8164 KB |
Output is correct |
23 |
Correct |
43 ms |
8164 KB |
Output is correct |
24 |
Correct |
53 ms |
8164 KB |
Output is correct |
25 |
Correct |
53 ms |
8164 KB |
Output is correct |