# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
843634 | 2023-09-04T10:05:44 Z | vjudge1 | Sure Bet (CEOI17_sure) | C++ | 118 ms | 3744 KB |
#define COPYRIGHT CODE BY TRINH TUAN NGHIA #include<bits/stdc++.h> #define Boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("popcnt") #define ll long long #define endl "\n" #define st first #define nd second #define ii pair <ll,ll> #define iii pair <ll,ii> #define iiii pair <ii,ii> #define pb push_back #define NAME "surebet" using namespace std; const ll N = 1e5 + 10; double a[N]; double b[N]; ll n; ll na, nb; double sa, sb; void inp (){ cin >> n; for (int i = 1; i <= n; ++i){ cin >> a[i] >> b[i]; } } void solve(){ double l = 0, r = 1e9; sort (a + 1,a + n + 1, greater<>()); sort (b + 1, b + n + 1, greater<>()); double ans =0 ; for (int j = 0 ; j <= 50; ++j){ double m = (l + r) / 2; sa = 0; sb = 0; na = 0; nb = 0; bool check = false; for (int i = 0; i<= 2 * n; ++i){ while (sa - i < m and na < n){ sa += a[na + 1]; //cout << "Dcm " << sa << " " << m << endl; ++na; } while (sb - i < m and nb < n){ sb += b[nb + 1]; ++nb; } while (sa - i - a[na] >= m){ sa -= a[na]; --na; } while (sb - i - b[nb] >=m){ sb -= b[nb]; --nb; } if (na + nb <= i and sa - i >= m and sb - i >= m){ check = true; ans = max(ans, m); } } if (check)l = m; else r = m; } cout << setprecision(4) << fixed << ans; } signed main (){ if (fopen(NAME".inp", "r")){ freopen(NAME".inp", "r", stdin); freopen(NAME".out", "w", stdout); } Boost; inp(); solve(); } /* input */ /* output */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 500 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 500 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 464 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 460 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 2 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 2 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 500 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 464 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 460 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 2 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 2 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 604 KB | Output is correct |
17 | Correct | 118 ms | 3156 KB | Output is correct |
18 | Correct | 116 ms | 3368 KB | Output is correct |
19 | Correct | 113 ms | 3368 KB | Output is correct |
20 | Correct | 118 ms | 3156 KB | Output is correct |
21 | Correct | 113 ms | 3736 KB | Output is correct |
22 | Correct | 114 ms | 3372 KB | Output is correct |
23 | Correct | 115 ms | 3372 KB | Output is correct |
24 | Correct | 115 ms | 3156 KB | Output is correct |
25 | Correct | 111 ms | 3368 KB | Output is correct |
26 | Correct | 107 ms | 3744 KB | Output is correct |