제출 #1289669

#제출 시각아이디문제언어결과실행 시간메모리
1289669MinhKien돌 무게 재기 (IZhO11_stones)C++20
100 / 100
40 ms4744 KiB
#include <iostream> using namespace std; const int N = 1e5 + 10; int n, x, y; struct SEG { int val[N << 2], lazy[N << 2]; void down(int id) { int lz = lazy[id]; if (lz == 0) return; val[id << 1] += lz; lazy[id << 1] += lz; val[id << 1 | 1] += lz; lazy[id << 1 | 1] += lz; lazy[id] = 0; } void update(int l, int r, int u, int v, int VAL, int id) { if (l > v || r < u) return; if (l >= u && r <= v) { val[id] += VAL; lazy[id] += VAL; return; } int mid = (l + r) >> 1; down(id); update(l, mid, u, v, VAL, id << 1); update(mid + 1, r, u, v, VAL, id << 1 | 1); val[id] = min(val[id << 1], val[id << 1 | 1]); } } one, two; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; ++i) { cin >> x >> y; if (y == 1) { one.update(1, n, 1, x, 1, 1); two.update(1, n, 1, x, -1, 1); } else { one.update(1, n, 1, x, -1, 1); two.update(1, n, 1, x, 1, 1); } if (one.val[1] >= 0) cout << ">\n"; else if (two.val[1] >= 0) cout << "<\n"; else cout << "?\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...