#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 11;
struct SegTree{
int mx[MAXN << 2], mn[MAXN << 2], s[MAXN << 2];
void add(int pos, int val, int v, int l, int r){
if(l == r){
mx[v] = mn[v] = s[v] = val;
return;
}
int m = (l + r) / 2;
if(pos <= m){
add(pos, val, v * 2 + 1, l, m);
}else{
add(pos, val, v * 2 + 2, m + 1, r);
}
s[v] = s[v * 2 + 1] + s[v * 2 + 2];
mx[v] = max(mx[v * 2 + 2], s[v * 2 + 2] + mx[v * 2 + 1]);
mn[v] = min(mn[v * 2 + 2], s[v * 2 + 2] + mn[v * 2 + 1]);
}
} segTree;
int main(){
int n; cin >> n;
for(int i = 0; i < n; i++){
int r, s; cin >> r >> s;
segTree.add(r, s == 1 ? 1 : -1, 0, 1, n);
if(segTree.mx[0] > 0 && segTree.mn[0] < 0){
cout << '?' << endl;
}else if(segTree.mx[0] > 0){
cout << '>' << endl;
}else{
cout << '<' << endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
3 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
16 ms |
780 KB |
Output is correct |
11 |
Correct |
100 ms |
2368 KB |
Output is correct |
12 |
Correct |
162 ms |
4172 KB |
Output is correct |
13 |
Correct |
175 ms |
4288 KB |
Output is correct |
14 |
Correct |
172 ms |
4300 KB |
Output is correct |
15 |
Correct |
169 ms |
4328 KB |
Output is correct |
16 |
Correct |
176 ms |
4276 KB |
Output is correct |
17 |
Correct |
167 ms |
4324 KB |
Output is correct |
18 |
Correct |
166 ms |
4300 KB |
Output is correct |
19 |
Correct |
175 ms |
4508 KB |
Output is correct |
20 |
Correct |
166 ms |
4300 KB |
Output is correct |
21 |
Correct |
168 ms |
4312 KB |
Output is correct |
22 |
Correct |
168 ms |
4328 KB |
Output is correct |
23 |
Correct |
171 ms |
4372 KB |
Output is correct |
24 |
Correct |
166 ms |
4280 KB |
Output is correct |
25 |
Correct |
169 ms |
4404 KB |
Output is correct |