#include <iostream>
#include <vector>
using namespace std;
int a[100005], b[100005], t[400005], lazy[400005], res[100005];
void push(int v) {
t[v * 2] += lazy[v];
t[v * 2 + 1] += lazy[v];
lazy[v * 2] += lazy[v];
lazy[v * 2 + 1] += lazy[v];
lazy[v] = 0;
}
void update(int v, int tl, int tr, int l, int r, int x) {
if (l > r) return;
if (tl == l && tr == r) {
t[v] += x;
lazy[v] += x;
return;
}
push(v);
int mid = (tl + tr) / 2;
update(v * 2, tl, mid, l, min(r, mid), x);
update(v * 2 + 1, mid + 1, tr, max(l, mid + 1), r, x);
t[v] = min(t[v * 2], t[v * 2 + 1]);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
}
for (int i = 1; i <= n; i++) {
if (b[i] == 1) {
update(1, 1, n, 1, a[i], -1);
}
else {
update(1, 1, n, 1, a[i] - 1, 1);
}
if (t[1] >= 0) res[i] = 1;
}
for (int i = 1; i <= n * 4; i++) t[i] = lazy[i] = 0;
for (int i = 1; i <= n; i++) {
if (b[i] == 2) {
update(1, 1, n, 1, a[i], -1);
}
else {
update(1, 1, n, 1, a[i] - 1, 1);
}
if (t[1] >= 0) res[i] = 2;
}
for (int i = 1; i <= n; i++) {
if (res[i] == 2) cout << '>';
else if (res[i] == 1) cout << '<';
else cout << '?';
cout << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 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 |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
5 ms |
2648 KB |
Output is correct |
11 |
Correct |
31 ms |
4028 KB |
Output is correct |
12 |
Correct |
49 ms |
5200 KB |
Output is correct |
13 |
Correct |
47 ms |
5716 KB |
Output is correct |
14 |
Correct |
52 ms |
5512 KB |
Output is correct |
15 |
Correct |
48 ms |
5708 KB |
Output is correct |
16 |
Correct |
48 ms |
5644 KB |
Output is correct |
17 |
Correct |
46 ms |
5456 KB |
Output is correct |
18 |
Correct |
47 ms |
5512 KB |
Output is correct |
19 |
Correct |
50 ms |
5712 KB |
Output is correct |
20 |
Correct |
46 ms |
5724 KB |
Output is correct |
21 |
Correct |
46 ms |
5716 KB |
Output is correct |
22 |
Correct |
51 ms |
5716 KB |
Output is correct |
23 |
Correct |
47 ms |
5716 KB |
Output is correct |
24 |
Correct |
55 ms |
5712 KB |
Output is correct |
25 |
Correct |
46 ms |
5692 KB |
Output is correct |