이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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));
}
cout<<ans<<endl;;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |