제출 #731641

#제출 시각아이디문제언어결과실행 시간메모리
731641rainboySwimming competition (LMIO18_plaukimo_varzybos)C11
100 / 100
453 ms11980 KiB
#include <stdio.h> #define N 1000000 #define INF 0x3f3f3f3f unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } void sort(int *xx, int l, int r) { while (l < r) { int i = l, j = l, k = r, x = xx[l + rand_() % (r - l)], tmp; while (j < k) if (xx[j] == x) j++; else if (xx[j] < x) { tmp = xx[i], xx[i] = xx[j], xx[j] = tmp; i++, j++; } else { k--; tmp = xx[j], xx[j] = xx[k], xx[k] = tmp; } sort(xx, l, i); l = k; } } int solve(int *xx, int n, int a, int b, int d) { static char dp[N + 1]; int i, i_, j; dp[0] = 1; for (i = 0, i_ = -1, j = 1; j <= n; j++) { if (j >= a && dp[j - a]) i_ = j - a; while (i < n && (j - i > b || xx[j - 1] - xx[i] > d)) i++; dp[j] = i_ >= i; } return dp[n]; } int main() { static int xx[N]; int n, a, b, i, lower, upper, d; scanf("%d%d%d", &n, &a, &b); for (i = 0; i < n; i++) scanf("%d", &xx[i]); sort(xx, 0, n); lower = -1, upper = INF; while (upper - lower > 1) { d = (lower + upper) / 2; if (solve(xx, n, a, b, d)) upper = d; else lower = d; } printf("%d\n", upper); return 0; }

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

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