Submission #8837

#TimeUsernameProblemLanguageResultExecution timeMemory
8837baneling100Weighting stones (IZhO11_stones)C++98
16 / 100
62 ms4156 KiB
#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) Idx[Loc] += Value; if(Left < Right) { Idx[2 * Loc] += Idx[Loc]; Idx[2 * Loc + 1] += Idx[Loc]; } Max[Loc] += Idx[Loc]; Min[Loc] += Idx[Loc]; Idx[Loc] = 0; if(Right > R) { 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 timeMemoryGrader output
Fetching results...