# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201664 | SamAnd | Pareto (COCI17_pareto) | C++17 | 77 ms | 3088 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 <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n;
int a[N];
int main()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(14);
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d", &a[i]);
sort(a + 1, a + n + 1);
reverse(a + 1, a + n + 1);
long double sum = 0;
for (int i = 1; i <= n; ++i)
sum += a[i];
long double ans1 = 1, ans2 = 1;
long double p = 0;
for (int i = 1; i <= n; ++i)
{
p += a[i];
long double yans1 = (i * 1.0) / n;
long double yans2 = p / sum;
if ((yans2 - yans1) > (ans2 - ans1))
{
ans1 = yans1;
ans2 = yans2;
}
}
cout << ans1 * 100 << endl << ans2 * 100 << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |