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 int long long
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
double a[n+1],b[n+1];
for(int i=1;i<=n;i++){
cin>>a[i]>>b[i];
a[i]--;
b[i]--;
}
sort(a+1,a+n+1,greater<double>());
sort(b+1,b+n+1,greater<double>());
int j=0;
double sa=0,sb=0,res=0;
for(int i=1;i<=n;i++){
sa+=a[i];
while(j<=n && (min(sa-j,sb-i)<min(sa-(j+1),(sb+b[j+1])-i))){
j++;
sb+=b[j];
}
res=max(res,min(sa-j,sb-i));
}
cout<<fixed<<setprecision(4)<<res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |