Submission #237303

# Submission time Handle Problem Language Result Execution time Memory
237303 2020-06-05T19:22:43 Z marlicu Pareto (COCI17_pareto) C++14
80 / 80
119 ms 4344 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

    vector <double> klijenti;
    klijenti.resize(n);

    double ukupno = 0;
    for (int i = 0; i < n; i++) {
        cin >> klijenti[i];
        ukupno += klijenti[i];
    }
    sort(klijenti.begin(), klijenti.end());
    reverse(klijenti.begin(), klijenti.end());

    double a = 100, b = 100;
    double a1, b1, koliko = 0;

    for (int i = 0; i < n; i++) {
        koliko += klijenti[i];

        a1 = (i + 1) / (double) n * 100;
        b1 = koliko / ukupno * 100;

        if ((b1 - a1) > (b - a)) {
            a = a1; b = b1;
        }

        //cout << i << " " << koliko << " " << ukupno << " : ";
        //cout << a1 << " " << b1 << '\n';
    }

    cout << a << '\n';
    cout << b << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 40 ms 1664 KB Output is correct
7 Correct 82 ms 3192 KB Output is correct
8 Correct 119 ms 4344 KB Output is correct