Submission #450422

#TimeUsernameProblemLanguageResultExecution timeMemory
450422rainboyPareto (COCI17_pareto)C11
80 / 80
77 ms2960 KiB
#include <stdio.h> #define N 300000 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, i_; long long sum, sum_, sum1, x, x_; scanf("%d", &n); sum_ = 0; for (i = 0; i < n; i++) { scanf("%d", &aa[i]); sum_ += aa[i]; } sort(aa, 0, n); sum = 0, x_ = 0, i_ = n, sum1 = 0; for (i = n - 1; i >= 0; i--) { sum += aa[i], x = (long long) sum * n - (long long) sum_ * (n - i); if (x_ < x) x_ = x, i_ = i, sum1 = sum; } printf("%f\n", (double) (n - i_) * 100 / n); printf("%f\n", (double) sum1 * 100 / sum_); return 0; }

Compilation message (stderr)

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