답안 #1035911

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035911 2024-07-26T18:35:30 Z mbalsells Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 348 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <assert.h>
#include <map>

using namespace std;

typedef long long int ll;
typedef vector <ll> vi;
typedef vector <vi> vvi;
typedef vector <double> vd;


int main (){
    cout.setf(ios::fixed);
    cout.precision(4);

    int n;
    cin >> n;

    vd A(n), B(n);

    for (int i = 0; i < n; ++i){
        cin >> A[i] >> B[i];
    }

    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());

    double pa = 0, pb = 0;
    int ia = 0, ib = 0; 

    double solution = 0;

    while (ia < n and ib < n){
        if (pa >= pb) {
            pa -= 1;
            pb += (B[ib] - 1);
            ++ib;
        }
        else {
            pb -= 1;
            pa += (A[ia] - 1);
            ++ia;
        }

        solution = max(solution, min(pa, pb));
    }

    cout << solution << endl;
}   

/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/




/*
4
1.4 4.7
1.2 2
1.6 1.4
1.9 1.5
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -