# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
311258 | bigg | Sure Bet (CEOI17_sure) | C++14 | 78 ms | 3580 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;
typedef double ll;
const int MAXN = 1e5 + 10;
ll prefa[MAXN], prefb[MAXN], a[MAXN], b[MAXN];
int n;
double cura = 0, curb = 0;
int main(){
scanf("%d", &n );
for(int i = 0; i < n; i++){
scanf("%lf %lf", &a[i], &b[i]);
}
sort(a , a + n);
sort(b , b + n);
reverse(a, a + n);
reverse(b, b + n);
double ans = 0;
int it1 = 0, it2 = 0;
for(int i = 0; i < 2*n; i++){
if(cura >= curb && it2 < n) curb += b[it2], it2++;
else if(cura < curb && it1 < n) cura += a[it1], it1++;
ans = max(ans, min(cura, curb) - i - 1);
}
printf("%.4lf\n", ans);
}
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... |