답안 #1111098

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111098 2024-11-11T13:37:29 Z Icelast Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 336 KB
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2*1e5+5, INF = 4e18+9;
const double eps = 1e-6;
void solve(){
    int n;
    cin >> n;
    vector<double> a(n+1), b(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
    }
    sort(a.begin()+1, a.end(), greater<double>());
    sort(b.begin()+1, b.end(), greater<double>());
    int pa = 1, pb = 1;
    double cura = 0, curb = 0;
    double ans = 0;
    auto cmp = [&](double a, double b) -> bool{
        return b-a > eps;
    };
    for(int i = 1; i <= 2*n; i++){
        if(pa > n){
            curb += b[pb];
            pb++;
            continue;
        }
        if(pb > n){
            cura += a[pa];
            pa++;
            continue;
        }
        if(cmp(cura, curb)){
            cura += a[pa];
            pa++;
        }else{
            curb += b[pb];
            pb++;
        }
        ans = max(ans, min(cura, curb)-i);
    }
    cout << fixed << setprecision(4) << ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -