# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
877983 | loncacbuoidai | Sure Bet (CEOI17_sure) | C++14 | 1 ms | 472 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, k;
float a[N], b[N];
bool check(float f) {
// cerr << fixed << setprecision(10) << f << '\n';
int x = ([&] () -> int {
int l = 1, r = n, ans = n * 3;
while (l <= r) {
int mid = (l + r) / 2;
if ((double)a[mid] - k >= f) {
ans = mid;
r = mid - 1;
} else l = mid + 1;
}
return ans;
}());
int y = ([&] () -> int {
int l = 1, r = n, ans = n * 3;
while (l <= r) {
int mid = (l + r) / 2;
if ((double)b[mid] - k >= f) {
ans = mid;
r = mid - 1;
} else l = mid + 1;
}
return ans;
}());
// cerr << x << ' ' << y << " ok " << (x + y <= k) << '\n';
return x + y <= k;
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("OXBET.inp", "r"))
freopen("OXBET.inp", "r", stdin),
freopen("OXBET.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i] >> b[i];
sort(a + 1, a + n + 1, greater<float>());
sort(b + 1, b + n + 1, greater<float>());
for (int i = 1; i <= n; i++)
a[i] += a[i - 1], b[i] += b[i - 1];
// for (int i = 1; i <= n; i++)
// cerr << a[i] << ' ' << b[i] << '\n';
// k = 3;
// check(0.5) << '\n';
// return 0;
float res = 0;
for (k = 1; k <= n * 2; k++) {
// cerr << "k = " << k << '\n';
float l = 0, r = 2e8, ans = 0;
for (int t = 1; t <= 50; t++) {
float mid = (l + r) / 2;
if (check(mid)) {
ans = mid;
l = mid;
} else r = mid;
}
res = max(res, ans);
}
cout << fixed << setprecision(4) << res;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |