Submission #24001

# Submission time Handle Problem Language Result Execution time Memory
24001 2017-05-29T05:14:46 Z Trathz Pareto (COCI17_pareto) C++14
80 / 80
126 ms 4364 KB
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define int long long
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define ieps (int) 1e5 + 800
#define eps (int) 1e9
#define jmp exit(0)


double pct(int x , int y){
   return  1.0*x/y;
}


int32_t main(){
	int n ; 
	cin>>n;
	vector<int> v(n);
	int s =  0;
	for(int i = 0;i<n;i++) cin>>v[i] , s+=v[i];
	sort(v.rbegin() , v.rend());
    int atual = 0;
    pair<double , double > tot = {0, 0};
    for(int i = 0;i<n;i++){
        atual+=v[i];
        pair<double , double > l = {pct(i + 1 , n) , pct(atual,s)};
        if(l.S - l.F> tot.S - tot.F){
        	tot = l;
        }
    } 
    cout<<fixed<<setprecision(9)<<tot.F*100.00<<endl<<tot.S*100.00;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 3 ms 2176 KB Output is correct
6 Correct 33 ms 2804 KB Output is correct
7 Correct 109 ms 3584 KB Output is correct
8 Correct 126 ms 4364 KB Output is correct