# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303045 | Kenzo_1114 | Sure Bet (CEOI17_sure) | C++17 | 73 ms | 1912 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;
const int MAXN = 100010;
int n;
double a[MAXN], b[MAXN];
double ans = 0.0000, sa = 0.0000, sb = 0.0000;
int main ()
{
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%lf %lf", &a[i], &b[i]);
sort(a, a + n); reverse(a, a + n);
sort(b, b + n); reverse(b, b + n);
int ida = 0, idb = 0;
for(int i = 0; i < 2 * n; i++)
{
if(sa >= sb && idb < n) sb += b[idb], idb++;
else if(sa < sb && ida < n) sa += a[ida], ida++;
ans = max(ans, min(sa, sb) - i - 1);
}
printf("%.4lf\n", (double) ans);
}
/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
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... |