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>
#define ll long long
#define MAXN 100010
using namespace std;
double a[MAXN],b[MAXN];
bool Cmp(double x,double y)
{
return x>=y;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n;
cin >> n;
for (ll i=1;i<=n;i++)
{
cin >> a[i] >> b[i];
a[i]-=1;
b[i]-=1;
}
sort(a+1,a+1+n,Cmp);
sort(b+1,b+1+n,Cmp);
double cura=0,curb=0,ans=0;
ll posb=1;
for (ll i=1;i<=n;i++)
{
cura+=a[i];
curb--;
while (posb<=n && min(cura-1,curb+b[posb])>=min(cura,curb))
{
curb+=b[posb];
cura--;
posb++;
}
ans=max(ans,min(cura,curb));
}
cout << fixed << setprecision(4) << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |