| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 45297 | bugmenot111 | Sure Bet (CEOI17_sure) | C++17 | 146 ms | 18492 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.
/*
maximize min(s[a] - (a + b), s[b] - (a + b))
min(s[a], s[b]) - (a + b)
min(s[a], s[b]) - b
*/
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <functional>
#define MAXN 100100
double a[MAXN];
double b[MAXN];
double pa[MAXN];
double pb[MAXN];
int n;
int main(void) {
double best = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++) {
scanf("%lf %lf", &a[i], &b[i]);
}
std::sort(a, a + n, std::greater<double>());
std::sort(b, b + n, std::greater<double>());
std::partial_sum(a, a + n, pa);
std::partial_sum(b, b + n, pb);
for(int i = 0; i < n; i++) {
double x = pa[i];
double y1 = 0, y2 = 0;
auto it = std::upper_bound(pb, pb + n, x);
if(it != pb + n) y1 = std::min(x, *it) - std::distance(pb, it) - i - 2;
if(it != pb) it = std::prev(it);
y2 = std::min(x, *it) - std::distance(pb, it) - i - 2;
best = std::max(best, std::max(y1, y2));
}
printf("%.4lf", best);
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... | ||||
