# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1027369 | vjudge1 | Sure Bet (CEOI17_sure) | C++17 | 53 ms | 1980 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 <stdio.h>
#include <algorithm>
#include <vector>
int main() {
int n;
scanf("%d", &n);
std::vector<double> a(n), b(n);
for (int i = 0; i < n; ++i) {
scanf("%lf %lf", &a[i], &b[i]);
a[i] -= 1;
b[i] -= 1;
}
std::sort(a.begin(), a.end());
std::reverse(a.begin(), a.end());
std::sort(b.begin(), b.end());
std::reverse(b.begin(), b.end());
int i = 0, j = 0;
double res = 0, sa = 0, sb = 0;
while (i < n) {
sa += a[i];
++i;
while ((j < n) && (std::min(sa - j, sb - i) < std::min(sa - j - 1, sb + b[j] - i))) {
sb += b[j];
++j;
}
res = std::max(res, std::min(sa - j, sb - i));
}
printf("%.4lf\n", 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... |