Submission #597468

#TimeUsernameProblemLanguageResultExecution timeMemory
597468zeroesandonesPareto (COCI17_pareto)C++17
80 / 80
44 ms3000 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define all(x) (x).begin(), (x).end()

#define sc second
#define fr first
#define pb push_back

void solve()
{
    int n;
    cin >> n;
    int a[n];
    double total = 0;
    FOR(i, 0, n) {
        cin >> a[i];
        total += a[i];
    }

    cout << fixed << setprecision(15);

    double sum = 0;
    pair<double, double> ans = {0.0, 0.0};

    sort(a, a+n, greater<int>());

    FOR(i, 0, n) {
        sum += a[i];
        double money = (sum / total);
        double people = ((double) (i + 1)) / ((double) (n));
        if(money - people > ans.sc - ans.fr)
            ans = {people, money};
    }

    cout << ans.fr * 100 << nl << ans.sc * 100<< nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...