# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
160256 | Akashi | Sure Bet (CEOI17_sure) | C++14 | 8 ms | 256 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;
double a[100005], b[100005];
int main()
{
// freopen("1.in", "r", stdin);
scanf("%d", &n);
for(int i = 1; i <= n ; ++i) scanf("%lf %lf", &a[i], &b[i]);
sort(a + 1, a + n + 1);
sort(b + 1, b + n + 1);
double st = 0, dr = 1e9;
int pasi = 69;
while(pasi--){
double mij = (st + dr) / 2;
int i = n, j = n, cost = 0;
double sum1 = 0, sum2 = 0;
while(i >= 0 && j >= 0){
if(sum1 - cost >= mij && sum2 - cost >= mij) break ;
if(sum1 - cost < mij){
++cost;
sum1 += a[i--];
}
else{
++cost;
sum2 += b[j--];
}
}
if(sum1 - cost < mij || sum2 - cost < mij) dr = mij;
else st = mij;
}
printf("%f", st);
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... |