Submission #100733

# Submission time Handle Problem Language Result Execution time Memory
100733 2019-03-13T19:39:44 Z dalgerok Pareto (COCI17_pareto) C++17
80 / 80
57 ms 3064 KB
#include<bits/stdc++.h>
using namespace std;


const int N = 3e5 + 5;


int n, a[N];
long long sum1, sum2;
long double ans, ans1, ans2;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum1 += a[i];
    }
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++){
        sum2 += a[i];
        long double cur1 = (i / (long double)n) * 100,
                    cur2 = (sum2 / (long double)sum1) * 100;
        if(cur2 - cur1 > ans){
            ans = cur2 - cur1;
            ans1 = cur1;
            ans2 = cur2;
        }
    }
    cout << fixed << setprecision(10) << ans1 << "\n" << ans2;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 18 ms 1280 KB Output is correct
7 Correct 36 ms 2424 KB Output is correct
8 Correct 57 ms 3064 KB Output is correct