Submission #660215

#TimeUsernameProblemLanguageResultExecution timeMemory
660215ajthelegendcoderPareto (COCI17_pareto)C++17
80 / 80
91 ms2972 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> arr(n); double sum = 0; double cnt = 0; double taken = 0; double sumtaken = 0; for(int i = 0; i < n; i++){ cin >> arr[i]; sum += arr[i]; cnt++; } sort(arr.begin(), arr.end()); reverse(arr.begin(), arr.end()); double maxt = 0, maxsum = 0; double range = 0; for(int i = 0; i < n; i++){ taken++; sumtaken += arr[i]; if(abs(taken/cnt * 100.0 - sumtaken/sum * 100.0) > range){ maxt = max(maxt, taken/cnt * 100.0); maxsum = max(maxsum, sumtaken/sum * 100.0); range = abs(taken/cnt * 100.0 - sumtaken/sum * 100.0); } } cout << setprecision(16) << maxt << endl << maxsum << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...