Submission #1301084

#TimeUsernameProblemLanguageResultExecution timeMemory
1301084tabPareto (COCI17_pareto)C++20
30 / 80
60 ms10196 KiB
#include "bits/stdc++.h"
using namespace std;
#define intt long long
#define fi first
#define se second

const intt mxN = 1e5+1;
const intt LG = 20;
const intt inf = 1e18;  

intt n, k;
double sum, tsum;
vector<double> a(mxN);

void _() {
    cin >> n;
    a.resize(n);
    for(intt i = 0; i < n; i++) {
        cin >> a[i]; tsum += a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    vector<double> p, s;
    double l =0;
    for(intt i = 0; i < n; i++) {
        sum += a[i];
        p.push_back((i+1)*100/n);
        s.push_back(sum*100/tsum);
        l = max(l, s.back() - p.back());
    }
    for(intt i = 0; i < n; i++) {
        if(l == s[i] - p[i]) {
            cout.precision(12);
            cout << fixed << p[i] << endl << s[i] << endl;
            return;
        }
    }
}

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

    // freopen("checklist.in", "r", stdin);
    // freopen("checklist.out", "w", stdout);

    intt t = 1, buu = 1;
    // cin >> t;
    while(t--){
        // cout << "Case #" << buu++ << ": ";
        _();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...