제출 #769986

#제출 시각아이디문제언어결과실행 시간메모리
769986rainboyHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C11
0 / 100
652 ms29576 KiB
#include <stdio.h> #define N 1000000 #define M 1000000 int max(int a, int b) { return a > b ? a : b; } unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } int aa[N]; int ll[M], rr[M], bb[M], ans[M]; void sort(int *hh, int l, int r) { while (l < r) { int i = l, j = l, k = r, h = hh[l + rand_() % (r - l)], tmp; while (j < k) if (rr[hh[j]] == rr[h]) j++; else if (rr[hh[j]] < rr[h]) { tmp = hh[i], hh[i] = hh[j], hh[j] = tmp; i++, j++; } else { k--; tmp = hh[j], hh[j] = hh[k], hh[k] = tmp; } sort(hh, l, i); l = k; } } int ft[N]; void update(int i, int n, int x) { while (i < n) { ft[i] = max(ft[i], x); i |= i + 1; } } int query(int i) { int x = 0; while (i >= 0) { x = max(x, ft[i]); i &= i + 1, i--; } return x; } int main() { static int hh[M], qu[N]; int n, m, cnt, h, h_, i, j; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) scanf("%d", &aa[i]); for (h = 0; h < m; h++) { scanf("%d%d%d", &ll[h], &rr[h], &bb[h]); hh[h] = h; } sort(hh, 0, m); cnt = 0; for (h = 0, j = 0; j < n; j++) { while (cnt && aa[qu[cnt - 1]] <= aa[j]) cnt--; if (cnt) { i = qu[cnt - 1]; update(n - 1 - i, n, aa[i] + aa[j]); } while (h < m && rr[h_ = hh[h]] == j) { ans[h_] = query(n - 1 - ll[h_]) <= bb[h_]; h++; } qu[cnt++] = j; } for (h = 0; h < m; h++) printf("%d\n", ans[h]); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

sortbooks.c: In function 'main':
sortbooks.c:59:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
sortbooks.c:61:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
sortbooks.c:63:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |   scanf("%d%d%d", &ll[h], &rr[h], &bb[h]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...