Submission #703034

#TimeUsernameProblemLanguageResultExecution timeMemory
703034rainboyWeighting stones (IZhO11_stones)C11
100 / 100
44 ms3640 KiB
#include <stdio.h> #define N_ (1 << 17) int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } int sum[N_ * 2], mn[N_ * 2], mx[N_ * 2], n_; void pul(int i) { int l = i << 1, r = l | 1; sum[i] = sum[l] + sum[r]; mn[i] = min(mn[l] + sum[r], mn[r]); mx[i] = max(mx[l] + sum[r], mx[r]); } void update(int i, int x) { i += n_; sum[i] = x, mn[i] = min(x, 0), mx[i] = max(x, 0); while (i > 1) pul(i >>= 1); } int main() { int n; scanf("%d", &n); n_ = 1; while (n_ < n) n_ <<= 1; while (n--) { int i, s; scanf("%d%d", &i, &s), i--; update(i, s == 1 ? 1 : -1); printf(mn[1] == 0 ? ">\n" : (mx[1] == 0 ? "<\n" : "?\n")); } return 0; }

Compilation message (stderr)

stones.c: In function 'main':
stones.c:28:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
stones.c:35:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf("%d%d", &i, &s), i--;
      |   ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...