Submission #1098612

# Submission time Handle Problem Language Result Execution time Memory
1098612 2024-10-09T16:09:31 Z flyingkite Sure Bet (CEOI17_sure) C++17
100 / 100
72 ms 3748 KB
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pll pair<long long, long long>
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
 
const ll N = 2e5 + 100;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll block = 480;
const ll eps = 0.0000001;
double a[N], b[N];
ll n;
void to_thic_cau(){  
    cin >> n;
    for(int i = 1; i <= n;i++) cin >> a[i] >> b[i];
    sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1);
    sort(b + 1, b + n + 1); reverse(b + 1, b + n + 1);
    for(int i = 1; i <= n;i++) a[i] += a[i-1];
    for(int i = 1; i <= n;i++) b[i] += b[i-1];
    double res = 0;
    for(int i = 0; i <= n;i++){
        ll l = 0, r = n, pos = -1;
        while(l <= r){
            ll mid = (l + r) / 2;
            if(b[mid] >= a[i] + eps){
                pos = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }
        if(pos == -1) continue;
        res = max(res, min(a[i], b[pos]) - 1.00 * (double(i + pos)));
    }
    for(int i = 0; i <= n;i++){
        ll l = 0, r = n, pos = -1;
        while(l <= r){
            ll mid = (l + r) / 2;
            if(a[mid] >= b[i] + eps){
                pos = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }
        if(pos == -1) continue;
        res = max(res, min(b[i], a[pos]) - 1.00 * (double(i + pos)));
    }
    cout << fixed << setprecision(4) << res << '\n';
}
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll tc = 1;
    //cin >> tc;
    while(tc--) to_thic_cau();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 472 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 472 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 57 ms 3164 KB Output is correct
18 Correct 60 ms 3164 KB Output is correct
19 Correct 59 ms 3156 KB Output is correct
20 Correct 57 ms 3372 KB Output is correct
21 Correct 62 ms 3676 KB Output is correct
22 Correct 59 ms 3156 KB Output is correct
23 Correct 58 ms 3152 KB Output is correct
24 Correct 59 ms 3156 KB Output is correct
25 Correct 72 ms 3156 KB Output is correct
26 Correct 62 ms 3748 KB Output is correct