#include <bits/stdc++.h>
using namespace std;
const int SZ = 1 << 17;
struct Node {
int mini = 0, maxi = 0;
};
Node st[2 * SZ];
int lazy[2 * SZ];
inline Node op(const Node &a, const Node &b) {
return {min(a.mini, b.mini), max(a.maxi, b.maxi)};
}
void pass(int u) {
if (u < SZ) {
lazy[2 * u] += lazy[u];
lazy[2 * u + 1] += lazy[u];
}
st[u].mini += lazy[u];
st[u].maxi += lazy[u];
lazy[u] = 0;
}
void update(int s, int e, int v, int l = 0, int r = SZ, int u = 1) {
pass(u);
if (e <= l || r <= s) return;
if (s <= l && r <= e) {
lazy[u] = v;
return pass(u);
}
int m = (l + r) / 2;
update(s, e, v, l, m, 2 * u);
update(s, e, v, m, r, 2 * u + 1);
st[u] = op(st[2 * u], st[2 * u + 1]);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int q;
cin >> q;
while (q--) {
int p, x;
cin >> p >> x;
update(0, p, -2 * x + 3);
if (st[1].maxi <= 0) {
cout << "<\n";
} else if (st[1].mini >= 0) {
cout << ">\n";
} else {
cout << "?\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2648 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 |
2392 KB |
Output is correct |
10 |
Correct |
4 ms |
2396 KB |
Output is correct |
11 |
Correct |
26 ms |
3316 KB |
Output is correct |
12 |
Correct |
41 ms |
3916 KB |
Output is correct |
13 |
Correct |
39 ms |
4180 KB |
Output is correct |
14 |
Correct |
38 ms |
3984 KB |
Output is correct |
15 |
Correct |
40 ms |
4228 KB |
Output is correct |
16 |
Correct |
48 ms |
4164 KB |
Output is correct |
17 |
Correct |
38 ms |
4072 KB |
Output is correct |
18 |
Correct |
39 ms |
4176 KB |
Output is correct |
19 |
Correct |
39 ms |
4176 KB |
Output is correct |
20 |
Correct |
40 ms |
4184 KB |
Output is correct |
21 |
Correct |
46 ms |
4340 KB |
Output is correct |
22 |
Correct |
40 ms |
4180 KB |
Output is correct |
23 |
Correct |
39 ms |
4056 KB |
Output is correct |
24 |
Correct |
41 ms |
4252 KB |
Output is correct |
25 |
Correct |
39 ms |
4176 KB |
Output is correct |