# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
523185 | redstonegamer22 | 돌 무게 재기 (IZhO11_stones) | C++17 | 1 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int offset = (1 << 17);
const int NMAX = 100000 + 7;
int lazy[2 * offset], maxs[2 * offset], mins[2 * offset];
void push_lazy(int node) {
maxs[node] += lazy[node];
mins[node] += lazy[node];
if(node < offset) {
lazy[2 * node] += lazy[node];
lazy[2 * node + 1] += lazy[node];
}
lazy[node] = 0;
}
void update(int node, int l, int r, int gl, int gr, int upd) {
if(r < gl || gr < l) return;
push_lazy(node);
if(gl <= l && r <= gr) {
lazy[node] += upd;
push_lazy(node);
return;
}
int mid = (l + r) / 2;
update(2 * node, l, mid, gl, gr, upd);
update(2 * node + 1, mid + 1, r, gl, gr, upd);
maxs[node] = max(maxs[2 * node], maxs[2 * node + 1]);
mins[node] = min(mins[2 * node], mins[2 * node + 1]);
return;
}
int main()
{
assert(offset > NMAX);
int n; cin >> n;
for(int i = 0; i < n; i++) {
int x, s; cin >> x >> s;
if(s == 1) update(1, 0, offset - 1, 0, x, +1);
else update(1, 0, offset - 1, 0, x, -1);
#ifdef LOCAL
cerr << '\t' << maxs[1] << " " << mins[1] << endl;
#endif // LOCAL
if(maxs[1] > 0 && mins[1] < 0) cout << '?' << endl;
else if(maxs[1] > 0) cout << '>' << endl;
else cout << '<' << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |