# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63154 | khsoo01 | Sure Bet (CEOI17_sure) | C++11 | 142 ms | 4412 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 N = 100005;
int n;
double a[N], b[N];
bool can (double P) {
double pa = 0, pb = 0;
int i = n, j = n;
while(true) {
bool upd = false;
while(i >= 1 && pa < P) {
pa -= 1.0; pb -= 1.0;
pa += a[i]; i--;
upd = true;
}
while(j >= 1 && pb < P) {
pa -= 1.0; pb -= 1.0;
pb += b[j]; j--;
upd = true;
}
if(!upd) break;
}
if(pa >= P && pb >= P) return true;
return false;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++) {
scanf("%lf%lf",&a[i],&b[i]);
}
sort(a+1, a+1+n);
sort(b+1, b+1+n);
double S = 0, E = 2e9;
for(int i=0;i<50;i++) {
double M = (S+E)/2;
can(M) ? S = M : E = M;
}
printf("%.4f\n",S);
}
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... |