답안 #136806

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
136806 2019-07-26T10:03:47 Z RiscadoA Pareto (COCI17_pareto) C++14
10 / 80
225 ms 4344 KB
#include <bits/stdc++.h>

const int MAX_N = 300000;

int N;
double A, B, C[MAX_N];

void solve()
{
        // Sort bank accounts
        std::sort(std::begin(C), std::begin(C) + N, std::greater<double>());
        
        // Get the total amount of money in the bank
        double sum_C = 0.0;
        for (int i = 0; i < N; ++i)
                sum_C += C[i];

        double cur_C = 0.0;
        A = 0.0;
        B = 0.0;
        for (int i = 0; i < N; ++i) {
                cur_C += C[i];
                
                double new_A = ((double)(i + 1) / (double)N) * 100.0;
                double new_B = (cur_C / sum_C) * 100.0;
                
                if (abs(new_B - new_A) < B - A)
                        break;
                A = new_A;
                B = new_B;
        }
}

int main()
{
        std::cin >> N;
        for (int i = 0; i < N; ++i)
                std::cin >> C[i];

        solve();

        std::cout << A << "\n" << B;
        return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Incorrect 3 ms 376 KB Output isn't correct
5 Incorrect 10 ms 504 KB Output isn't correct
6 Incorrect 73 ms 1656 KB Output isn't correct
7 Incorrect 163 ms 3296 KB Output isn't correct
8 Incorrect 225 ms 4344 KB Output isn't correct