Submission #136814

#TimeUsernameProblemLanguageResultExecution timeMemory
136814RiscadoAPareto (COCI17_pareto)C++14
80 / 80
234 ms3348 KiB
#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 (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 timeMemoryGrader output
Fetching results...