# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1027438 | vjudge1 | Sure Bet (CEOI17_sure) | C++14 | 61 ms | 4588 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 <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define double long double
const int MAXN = 100086;
int main() {
int n;
vector<double> a(MAXN), b(MAXN);
double sum1 = 0, sum2 = 0, maxx = 0;
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%Lf %Lf", &a[i], &b[i]);
sort(a.begin() + 1, a.end(), greater<double>());
sort(b.begin() + 1, b.end(), greater<double>());
int r = 1;
for (int l = 1; l <= n; ++l) {
sum1 += a[l];
double res = 0;
while (true) {
res = min(sum1, sum2) - l - r + 1;
if (min(sum1, sum2 + b[r]) - l - r > res) {
sum2 += b[r++];
if (r > n) break;
} else {
break;
}
}
maxx = max(maxx, min(sum1, sum2) - l - r + 1);
}
printf("%.4Lf", maxx);
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... |