# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
450422 |
2021-08-02T20:47:43 Z |
rainboy |
Pareto (COCI17_pareto) |
C |
|
77 ms |
2960 KB |
#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
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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
284 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
23 ms |
1100 KB |
Output is correct |
7 |
Correct |
50 ms |
2280 KB |
Output is correct |
8 |
Correct |
77 ms |
2960 KB |
Output is correct |