# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136806 | RiscadoA | Pareto (COCI17_pareto) | C++14 | 225 ms | 4344 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>
const int MAX_N = 300000;
int N;
double A, B, C[MAX_N];
void solve()
{
// Sort bank accounts
std::sort(std::begin(C), std::begin(C) + N, std::greater<double>());
// Get the total amount of money in the bank
double sum_C = 0.0;
for (int i = 0; i < N; ++i)
sum_C += C[i];
double cur_C = 0.0;
A = 0.0;
B = 0.0;
for (int i = 0; i < N; ++i) {
cur_C += C[i];
double new_A = ((double)(i + 1) / (double)N) * 100.0;
double new_B = (cur_C / sum_C) * 100.0;
if (abs(new_B - new_A) < B - A)
break;
A = new_A;
B = new_B;
}
}
int main()
{
std::cin >> N;
for (int i = 0; i < N; ++i)
std::cin >> C[i];
solve();
std::cout << A << "\n" << B;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |