답안 #872564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872564 2023-11-13T11:27:44 Z vjudge1 Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 348 KB
//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

#define ONLINE_JUDGE
void solve() {
    int n;
    cin >> n;

    double a[n], b[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    sort(a, a + n);
    sort(b, b + n);

    double ans = 0;
    for(int i = 0; i < n * 2; i++) {
        double calc1 = 0, calc2 = 0;
        int ptr1 = n -1, ptr2 = n -1;
        for(int j = 0; j < i; j++) {
            if(calc1 <= calc2) {
                if(ptr1 >= 0) {
                    calc1 += a[ptr1];
                    ptr1--;
                } else {
                    calc2 += b[ptr2];
                    ptr2--;
                }
            } else {
                if(ptr2 >= 0) {
                    calc2 += b[ptr2];
                    ptr2--;
                } else {
                    calc1 += a[ptr1];
                    ptr1--;
                }
            } 
        }

        //cerr << i << " :: " << calc1 << " " << calc2 << "\n";
        ans = max(ans, min(calc1, calc2) - i);
    }

    printf("%.4lf", double(ans));
    
    return;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen(".in", "r", stdin);
        freopen(".out", "w", stdout);
    #endif

    int t = 1; //cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -