Submission #1027336

# Submission time Handle Problem Language Result Execution time Memory
1027336 2024-07-19T03:47:24 Z coldbr3w Sure Bet (CEOI17_sure) C++17
100 / 100
69 ms 2788 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 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 56 ms 2692 KB Output is correct
18 Correct 56 ms 2648 KB Output is correct
19 Correct 57 ms 2692 KB Output is correct
20 Correct 54 ms 2648 KB Output is correct
21 Correct 59 ms 2788 KB Output is correct
22 Correct 69 ms 2648 KB Output is correct
23 Correct 67 ms 2680 KB Output is correct
24 Correct 60 ms 2568 KB Output is correct
25 Correct 55 ms 2648 KB Output is correct
26 Correct 61 ms 2648 KB Output is correct