#include <bits/stdc++.h>
using namespace std;
double a[100005],b[100005],k,l,r,k1,ans;
int n,fs;
int main()
{
cin>>n;
for (int i=1; i<=n; i++)
{
cin>>a[i]>>b[i];
}
sort(a+1, a+n+1);
sort(b+1, b+n+1);
for (int i=n; i>=1; i--)
{
if (k+a[i]>l)
{
k+=a[i];
l=k;
fs++;
}
ans=max(ans,min(l-fs,r-fs));
if (k1+b[i]>r)
{
k1+=b[i];
r=k1;
fs++;
}
ans=max(ans,min(l-fs,r-fs));
}
printf("%.4lf",(double)ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |