# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
570721 | radaiosm7 | Sure Bet (CEOI17_sure) | C++98 | 85 ms | 3584 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;
int n, i, j;
double a[100005];
double b[100005];
double ans, profa, profb;
int main() {
scanf("%d", &n);
for (i=0; i < n; ++i) {
scanf("%lf", &a[i]);
scanf("%lf", &b[i]);
}
sort(a, a+n, greater<double>());
sort(b, b+n, greater<double>());
ans = 0.0;
i = 0;
j = 0;
while (i < n && j < n) {
profa -= 1.0;
profb -= 1.0;
if (profa < profb) profa += a[i++];
else profb += b[j++];
ans = max(ans, min(profa, profb));
}
if (i == n) while (j < n) {
profa -= 1.0;
profb += b[j++]-1.0;
ans = max(ans, min(profa, profb));
}
else if (j == n) while (i < n) {
profa += a[i++]-1.0;
profb -= 1.0;
ans = max(ans, min(profa, profb));
}
printf("%.4lf\n", 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... |