Submission #491000

# Submission time Handle Problem Language Result Execution time Memory
491000 2021-11-30T03:10:32 Z kawaii Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>
using namespace std; 
 
int n;
long double a[100005], b[100005], sum[100005], ans = 0; 

void solve(){  
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    for(int i = n; i >= 1; i--) sum[i] = sum[i + 1] + b[i];
    long double suma = 0;
    for(int i = n; i >= 1; i--){
        suma += a[i];
        int l = 0, r = n + 1;
        while(r - l > 1){
            int mid = (l + r) / 2;
            if(sum[mid] > suma) l = mid;
            else r = mid;
        }
        int num = (n - i + 1) + (n - r + 1); 
        ans = max(ans, min(suma, sum[r]) - num);
        ans = max(ans, min(suma, sum[r] + b[l]) - num - 1); 
    }
    cout << ans;
}
 
signed main(){  
    ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i] >> b[i]; 
    solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -