제출 #545918

#제출 시각아이디문제언어결과실행 시간메모리
545918rainboyGlobal Warming (CEOI18_glo)C11
100 / 100
162 ms8400 KiB
#include <stdio.h> #define N 200000 int max(int a, int b) { return a > b ? a : b; } unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } int aa[N * 2]; void sort(int *ii, int l, int r) { while (l < r) { int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp; while (j < k) if (aa[ii[j]] == aa[i_]) j++; else if (aa[ii[j]] < aa[i_]) { tmp = ii[i], ii[i] = ii[j], ii[j] = tmp; i++, j++; } else { k--; tmp = ii[j], ii[j] = ii[k], ii[k] = tmp; } sort(ii, l, i); l = k; } } void update(int *ft, int i, int n, int x) { while (i < n) { ft[i] = max(ft[i], x); i |= i + 1; } } int query(int *ft, int i) { int x = 0; while (i >= 0) { x = max(x, ft[i]); i &= i + 1, i--; } return x; } int main() { static int ii[N * 2], ft1[N * 2], ft2[N * 2], dp[N], dq[N]; int n, x, i, a; scanf("%d%d", &n, &x); for (i = 0; i < n; i++) scanf("%d", &aa[i]), aa[n + i] = aa[i] + x; for (i = 0; i < n * 2; i++) ii[i] = i; sort(ii, 0, n * 2); for (i = 0, a = 0; i < n * 2; i++) aa[ii[i]] = i + 1 == n * 2 || aa[ii[i + 1]] != aa[ii[i]] ? a++ : a; for (i = 0; i < n; i++) { dp[i] = query(ft1, aa[i] - 1) + 1; dq[i] = query(ft2, aa[n + i] - 1) + 1; update(ft1, aa[i], n * 2, dp[i]), update(ft2, aa[i], n * 2, dp[i]); update(ft2, aa[n + i], n * 2, dq[i]); } printf("%d\n", max(query(ft1, n * 2 - 1), query(ft2, n * 2 - 1))); return 0; }

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

glo.c: In function 'main':
glo.c:55:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |  scanf("%d%d", &n, &x);
      |  ^~~~~~~~~~~~~~~~~~~~~
glo.c:57:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |   scanf("%d", &aa[i]), aa[n + i] = aa[i] + x;
      |   ^~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...