답안 #739002

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
739002 2023-05-09T18:23:22 Z Unforgettablepl Pareto (COCI17_pareto) C++17
80 / 80
110 ms 6556 KB
/*
ID: samikgo1
TASK:
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long double ll;
typedef pair<ll,ll> pii;
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
//#define f first
//#define s second
//#define x first
//#define y second
const int INF = INT32_MAX;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("measurement.in","r",stdin);
//    freopen("measurement.out","w",stdout);
    int n;
    cin >> n;
    vector<ll> acc(n);
    ll sum = 0;
    for(ll&i:acc){cin>>i;sum+=i;}
    sort(allr(acc));
    ll A = 0;
    ll B = 0;
    ll ans = INT32_MIN;
    ll curr_sum = 0;
    for (ll i = 0; i < n; i++) {
        curr_sum+=acc[i];
        if(ans<abs((curr_sum/sum)-((i+1)/n))){
            ans = abs((curr_sum/sum)-((i+1)/n));
            A = ((i+1)/n);
            B = (curr_sum/sum);
        }
    }
    cout << A*100 << ' ' << B*100;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 4 ms 456 KB Output is correct
6 Correct 36 ms 2388 KB Output is correct
7 Correct 79 ms 4608 KB Output is correct
8 Correct 110 ms 6556 KB Output is correct