# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
868391 | lovrot | Sure Bet (CEOI17_sure) | C++17 | 72 ms | 5208 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 <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
typedef long double ld;
const int N = 1e5 + 10;
int n;
ld A[N], B[N];
ld solve() {
ld ret = 0, sum = 0, _sum = 0;
for(int i = 0, j = 0; i < n; ++i) {
sum += A[i];
for(; j < n && _sum < sum; ++j) _sum += B[j];
if(j == n && _sum < sum) break;
ret = max(ret, sum - (ld) i - (ld) j - 1.0);
}
return ret;
}
int main() {
scanf("%d", &n);
for(int i = 0; i < n; ++i) scanf("%LF%LF", A + i, B + i);
sort(A, A + n, [](ld a, ld b) { return a > b; });
sort(B, B + n, [](ld a, ld b) { return a > b; });
ld ans = solve();
swap(A, B);
ans = max(ans, solve());
printf("%.4lf\n", (double) ans);
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... |