Submission #237303

#TimeUsernameProblemLanguageResultExecution timeMemory
237303marlicuPareto (COCI17_pareto)C++14
80 / 80
119 ms4344 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector <double> klijenti; klijenti.resize(n); double ukupno = 0; for (int i = 0; i < n; i++) { cin >> klijenti[i]; ukupno += klijenti[i]; } sort(klijenti.begin(), klijenti.end()); reverse(klijenti.begin(), klijenti.end()); double a = 100, b = 100; double a1, b1, koliko = 0; for (int i = 0; i < n; i++) { koliko += klijenti[i]; a1 = (i + 1) / (double) n * 100; b1 = koliko / ukupno * 100; if ((b1 - a1) > (b - a)) { a = a1; b = b1; } //cout << i << " " << koliko << " " << ukupno << " : "; //cout << a1 << " " << b1 << '\n'; } cout << a << '\n'; cout << b << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...