# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51385 | adamczh1 | Sure Bet (CEOI17_sure) | C++17 | 182 ms | 2256 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 MAXN = 1e5 + 5;
int n;
double a[MAXN], b[MAXN];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lf %lf", &a[i], &b[i]);
}
sort(a, a + n);
reverse(a, a + n);
sort(b, b + n);
reverse(b, b + n);
double lo = 0;
double hi = 2e9;
for (int iter = 0; iter < 200; iter++) {
double mid = (lo + hi) / 2;
double x = 0, y = 0;
int ai = 0, bi = 0;
while (ai < n || bi < n) {
if (x < mid) {
x += a[ai++] - 1;
y--;
}
if (y < mid) {
x--;
y += b[bi++] - 1;
}
if (x >= mid && y >= mid) {
break;
}
}
if (x >= mid && y >= mid) {
lo = mid;
} else {
hi = mid;
}
}
printf("%.4lf", lo);
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... |