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 <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
const int maxn=1e5+5;
double a[maxn], b[maxn];
bool cmp(double x, double y){
return x>y;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout << fixed;
cout << setprecision(4);
int n;
cin >> n;
for(int i=0; i<n; i++){
cin >> a[i] >> b[i];
}
sort(a, a+n, cmp);
sort(b, b+n, cmp);
int ind1=0, ind2=0;
double p1=0, p2=0;
double maksi=0;
while(true){
p1--;
p2--;
if(p1<p2){
if(ind1==n){
break;
}
p1+=a[ind1];
ind1++;
}
else{
if(ind2==n){
break;
}
p2+=b[ind2];
ind2++;
}
// cout << p1 << ' ' << p2 << endl;
maksi=max(maksi, min(p1, p2));
}
cout << maksi << '\n';
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... |