#include <bits/stdc++.h>
using namespace std;
const int NM = 1e5;
struct node{
int mn, mx;
};
int N;
node st[4*NM+5];
int lazy[4*NM+5];
void apply(int id, int val){
st[id].mn += val;
st[id].mx += val;
}
void down(int id){
apply(2*id, lazy[id]); apply(2*id+1, lazy[id]);
lazy[2*id] += lazy[id], lazy[2*id+1] += lazy[id];
lazy[id] = 0;
}
node operator + (node a, node b){
node c;
c.mn = min(a.mn, b.mn);
c.mx = max(a.mx, b.mx);
return c;
}
void update(int id, int l, int r, int u, int v, int val){
if (v < l || u > r) return;
if (l >= u && r <= v){
apply(id, val);
lazy[id] += val;
return;
}
down(id);
int mid = (l+r)/2;
update(2*id, l, mid, u, v, val);
update(2*id+1, mid+1, r, u, v, val);
st[id] = st[2*id]+st[2*id+1];
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N;
for (int i = 1; i <= N; i++){
int R, S; cin >> R >> S;
R = N-R+1;
if (S == 1){
update(1, 1, N, R, N, 1);
}
else{
update(1, 1, N, R, N, -1);
}
if (st[1].mn >= 0) cout << '>';
else if (st[1].mx <= 0) cout << '<';
else cout << '?';
cout << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2508 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 |
2520 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
2 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
3 ms |
2692 KB |
Output is correct |
11 |
Correct |
19 ms |
5212 KB |
Output is correct |
12 |
Correct |
32 ms |
5584 KB |
Output is correct |
13 |
Correct |
31 ms |
5468 KB |
Output is correct |
14 |
Correct |
36 ms |
5460 KB |
Output is correct |
15 |
Correct |
32 ms |
5476 KB |
Output is correct |
16 |
Correct |
34 ms |
5608 KB |
Output is correct |
17 |
Correct |
32 ms |
5616 KB |
Output is correct |
18 |
Correct |
32 ms |
5460 KB |
Output is correct |
19 |
Correct |
31 ms |
5468 KB |
Output is correct |
20 |
Correct |
32 ms |
5460 KB |
Output is correct |
21 |
Correct |
36 ms |
5464 KB |
Output is correct |
22 |
Correct |
37 ms |
5528 KB |
Output is correct |
23 |
Correct |
32 ms |
5460 KB |
Output is correct |
24 |
Correct |
39 ms |
5572 KB |
Output is correct |
25 |
Correct |
32 ms |
5468 KB |
Output is correct |