Submission #1027651

# Submission time Handle Problem Language Result Execution time Memory
1027651 2024-07-19T08:24:41 Z vjudge1 Sure Bet (CEOI17_sure) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define f first
#define s second

void solve(){
    int n;
    cin >> n;
    vector<double> a(n), b(n);
    double ans = 0;
    for(int i =  0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    double x = 0, y = 0;
    int i = 0, j = 0, tu = 0;
    while(i < n && j < n){
        if(x <= y){
            x+=a[i];
            tu++;
            i++;
        }
        else{
            y+=b[j];
            tu++;
            j++;
        }
        ans=max(ans, min(x, y)-tu);
    }
    printf("%.4lf",(double)ans);
    // cout << fixed << setprecision(4) << ans << endl;
}   

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    
}
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -