Submission #392845

#TimeUsernameProblemLanguageResultExecution timeMemory
392845rainboyAkcija (COCI15_akcija)C11
80 / 80
24 ms1228 KiB
#include <stdio.h> #define N 100000 unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } void sort(int *aa, int l, int r) { while (l < r) { int i = l, j = l, k = r, a = aa[l + rand_() % (r - l)], tmp; while (j < k) if (aa[j] == a) j++; else if (aa[j] < a) { tmp = aa[i], aa[i] = aa[j], aa[j] = tmp; i++, j++; } else { k--; tmp = aa[j], aa[j] = aa[k], aa[k] = tmp; } sort(aa, l, i); l = k; } } int main() { static int aa[N]; int n, i; long long ans; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &aa[i]); sort(aa, 0, n); ans = 0; for (i = 0; i < n; i++) if ((n - i) % 3 != 0) ans += aa[i]; printf("%lld\n", ans); return 0; }

Compilation message (stderr)

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