# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
450422 | rainboy | Pareto (COCI17_pareto) | C11 | 77 ms | 2960 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |