# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
660215 | ajthelegendcoder | Pareto (COCI17_pareto) | C++17 | 91 ms | 2972 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;
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |