Submission #733408

#TimeUsernameProblemLanguageResultExecution timeMemory
733408rainboy대표 선수 (KOI11_player)C11
0 / 20
109 ms5388 KiB
#include <stdio.h> #define N 1000 #define M 1000 #define INF 0x3f3f3f3f int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } int aa[N * 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 (aa[hh[j]] == aa[h]) j++; else if (aa[hh[j]] < aa[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 main() { static int hh[N * M]; int n, m, h, h_, i, j, a, ans; scanf("%d%d", &n, &m); for (h = 0; h < n * m; h++) { scanf("%d", &aa[h]); hh[h] = h; } sort(hh, 0, n * m); a = 0; for (i = 0; i < n; i++) a = max(a, aa[i * m + 0]); ans = INF; for (h = 0; h < n * m; h++) { h_ = hh[h], i = h_ / m, j = h_ % m; ans = min(ans, a - aa[h_]); if (j + 1 == m) break; a = max(a, aa[i * m + j + 1]); } printf("%d\n", ans); return 0; }

Compilation message (stderr)

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