#include <iostream>
#include <cmath>
#include <cctype>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <unordered_set>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <random>
#include <cfloat>
#include <chrono>
#include <bitset>
#include <complex>
#include <immintrin.h>
#include <cassert>
std::pair<int32_t, int32_t>* segtree;
int32_t* lazy;
void propagate(int32_t node) {
segtree[node * 2 + 1].first += lazy[node];
segtree[node * 2 + 1].second += lazy[node];
lazy[node * 2 + 1] += lazy[node];
segtree[node * 2 + 2].first += lazy[node];
segtree[node * 2 + 2].second += lazy[node];
lazy[node * 2 + 2] += lazy[node];
lazy[node] = 0;
}
void add(int32_t node, int32_t left, int32_t right, int32_t query_left, int32_t query_right, int32_t x) {
if(left >= query_right || right <= query_left)
return;
if(left >= query_left && right <= query_right) {
segtree[node].first += x;
segtree[node].second += x;
lazy[node]+=x;
return;
}
int32_t m = (left + right) / 2;
propagate(node);
add(node * 2 + 1, left, m, query_left, query_right, x);
add(node * 2 + 2, m, right, query_left, query_right, x);
segtree[node].first = std::min(segtree[node * 2 + 1].first, segtree[node * 2 + 2].first);
segtree[node].second = std::max(segtree[node * 2 + 1].second, segtree[node * 2 + 2].second);
}
int main() {
int32_t n;
std::cin >> n;
segtree = new std::pair<int32_t, int32_t>[n * 4];
lazy = new int32_t[n * 4];
for(int32_t i = 0; i < n * 4; i++) {
segtree[i] = {0, 0};
lazy[i] = 0;
}
for(int32_t i = 0; i < n; i++) {
int32_t x, set;
std::cin >> x >> set;
if(set == 1) {
add(0, 0, n, n - x, n, 1);
} else {
add(0, 0, n, n - x, n, -1);
}
bool can_1 = segtree[0].second > 0;
bool can_2 = segtree[0].first < 0;
if(can_1 && can_2)
std::cout << '?' << "\n";
else if(can_1)
std::cout << '>' << "\n";
else
std::cout << "<" << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
2 |
Correct |
1 ms |
272 KB |
Output is correct |
3 |
Correct |
1 ms |
272 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
3 ms |
296 KB |
Output is correct |
8 |
Correct |
4 ms |
336 KB |
Output is correct |
9 |
Correct |
3 ms |
336 KB |
Output is correct |
10 |
Correct |
29 ms |
772 KB |
Output is correct |
11 |
Correct |
139 ms |
3464 KB |
Output is correct |
12 |
Correct |
215 ms |
5356 KB |
Output is correct |
13 |
Correct |
240 ms |
5860 KB |
Output is correct |
14 |
Correct |
307 ms |
5952 KB |
Output is correct |
15 |
Correct |
241 ms |
5952 KB |
Output is correct |
16 |
Correct |
209 ms |
5948 KB |
Output is correct |
17 |
Correct |
241 ms |
5932 KB |
Output is correct |
18 |
Correct |
208 ms |
5948 KB |
Output is correct |
19 |
Correct |
236 ms |
5924 KB |
Output is correct |
20 |
Correct |
237 ms |
5892 KB |
Output is correct |
21 |
Correct |
235 ms |
5988 KB |
Output is correct |
22 |
Correct |
252 ms |
5928 KB |
Output is correct |
23 |
Correct |
257 ms |
5956 KB |
Output is correct |
24 |
Correct |
263 ms |
5924 KB |
Output is correct |
25 |
Correct |
254 ms |
5900 KB |
Output is correct |