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;
void read(vector<double> &a , vector<double> &b , int &n)
{
cin>>n;
a.assign(n , 0);
b = a;
for(int i = 0 ;i < n ; i++)
{
cin>>a[i]>>b[i];
}
}
void brute(vector<double> &a , vector<double> &b , int &n)
{
n = rand()%10 + 1;
a.assign(n , 0);
b = a;
for(int i = 0 ;i < n ; i++)
{
a[i] = rand()%5 + 4;
b[i] = rand()%5 + 4;
}
}
int main()
{
int n ;
vector<double> a , b;
read(a , b , n);
sort(a.rbegin() , a.rend());
sort(b.rbegin() , b.rend());
double ans1 = 0;
for(int i = 0 ; i < n ; i++)
{
a[i]--;
b[i]--;
}
for(int i = 1 ; i < n ; i++)
{
a[i]+=a[i - 1];
b[i]+=b[i - 1];
}
for(int na = 1; na <= n ; na++)
{
double lo = 0 , hi = a[na - 1] - 1;
for(int i = 0 ; i < 40 ; i++)
{
double md = (lo + hi)/2;
if(b[max(0 , min((int)floor(a[na - 1] - md - 1) , n - 1))] >= na + md)
{
lo = md;
}
else
hi = md;
}
ans1 = max(ans1 , lo);
}
printf("%.4lf",(double)ans1);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |