Submission #473634

#TimeUsernameProblemLanguageResultExecution timeMemory
473634rainboyVrtić (COCI18_vrtic)C11
32 / 160
1 ms280 KiB
#include <stdio.h> #define N 150 int max(int a, int b) { return a > b ? a : b; } 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 main() { static int pp[N], xx[N]; int n, i, ans; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &pp[i]); for (i = 0; i < n; i++) scanf("%d", &xx[i]); sort(xx, 0, n); if (n == 2) ans = xx[1] - xx[0]; else { ans = 0; for (i = 2; i < n; i++) ans = max(ans, xx[i] - xx[i - 2]); } printf("%d\n", ans); for (i = 0; i < n; i += 2) printf("%d ", xx[i]); for (i = n % 2 == 0 ? n - 1 : n - 2; i >= 0; i -= 2) printf("%d ", xx[i]); printf("\n"); return 0; }

Compilation message (stderr)

vrtic.c: In function 'main':
vrtic.c:36:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
vrtic.c:38:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |   scanf("%d", &pp[i]);
      |   ^~~~~~~~~~~~~~~~~~~
vrtic.c:40:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |   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...
#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...