답안 #597468

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
597468 2022-07-16T04:53:56 Z zeroesandones Pareto (COCI17_pareto) C++17
80 / 80
44 ms 3000 KB
#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();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 352 KB Output is correct
6 Correct 20 ms 704 KB Output is correct
7 Correct 33 ms 2324 KB Output is correct
8 Correct 44 ms 3000 KB Output is correct