# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
13247 | baneling100 | Weighting stones (IZhO11_stones) | C++98 | 61 ms | 4156 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <algorithm>
using namespace std;
int N, R, S, M, Value, Max[262144], Min[262144], Idx[262144];
void SegTree(int Left, int Right, int Loc) {
int Mid = (Left + Right) / 2;
if(Right <= R) {
Max[Loc] += Value;
Min[Loc] += Value;
Idx[Loc] += Value;
}
else {
Max[2 * Loc] += Idx[Loc];
Min[2 * Loc] += Idx[Loc];
Idx[2 * Loc] += Idx[Loc];
Max[2 * Loc + 1] += Idx[Loc];
Min[2 * Loc + 1] += Idx[Loc];
Idx[2 * Loc + 1] += Idx[Loc];
Idx[Loc] = 0;
SegTree(Left, Mid, 2 * Loc);
if(Mid + 1 <= R)
SegTree(Mid + 1, Right, 2 * Loc + 1);
Max[Loc] = max(Max[2 * Loc], Max[2 * Loc + 1]);
Min[Loc] = min(Min[2 * Loc], Min[2 * Loc + 1]);
}
}
int main(void) {
int i;
scanf("%d", &N);
for(M = 1 ; M < N ; M *= 2);
for(i = 1 ; i <= N ; i++) {
scanf("%d %d", &R, &S);
if(S == 1)
Value = 1;
else
Value = -1;
SegTree(1, M, 1);
if(Min[1] >= 0)
printf(">\n");
else if(Max[1] <= 0)
printf("<\n");
else
printf("?\n");
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |