Submission #873619

# Submission time Handle Problem Language Result Execution time Memory
873619 2023-11-15T11:39:29 Z vjudge1 Pareto (COCI17_pareto) C++17
80 / 80
42 ms 7700 KB
#include<bits/stdc++.h>
#ifdef LOCAL
#include "Essentials/algo/debug.h"
#else
#define debug(...) 69
#endif
using namespace std;

typedef long long     ll;
typedef pair<int,int> pii;
typedef long double   ldb;

const int N = 3e5 + 23;
const ll inf = 1e18;

#define F           first
#define S           second
#define pb          push_back
#define kill(x)     cout<<x<<endl, exit(0);
#define all(x)      x.begin(),x.end()
#define sz(x)       (int)x.size()
#define lc          (v << 1)
#define rc          ((v<<1) |1)
#define int         ll

int n;
vector<int> vals;

pair< ldb, pair<ldb,ldb>> ans= {0.0 , {100.0 , 100.0}};

int32_t main() {
    cin.tie(nullptr)->sync_with_stdio(false);
	cin>>n;
	int sum = 0;
	for(int i = 0 ; i<n ; i++) {
		int x; cin>>x;
		vals.pb(x);
		sum += x;
	}
	sort(all(vals),greater<>());
	int sum1= 0;
	for(int i = 0 ; i< n ; i++) {
		sum1 += vals[i];
		ldb A = (i+1)*1.0 / n;
		ldb B = sum1*1.0 / sum;
		ans = max(ans, {B-A, {A,B}});
	}
	cout<<fixed << ans.S.F*100 << '\n'<< ans.S.S*100 << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 13 ms 2036 KB Output is correct
7 Correct 28 ms 3544 KB Output is correct
8 Correct 42 ms 7700 KB Output is correct