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>
using namespace std;
void update(double &best , double even , double odd){
best = max(best , min(even , odd));
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<double> one(n) , two(n);
for(int i = 0 ; i < n ; i++){
cin >> one[i] >> two[i];
}
sort(one.rbegin(),one.rend());
sort(two.rbegin(),two.rend());
double even = 0 , odd = 0;
double best = 0;
int i = 0 , j = 0;
while(i < n || j < n){
if(even < odd && i < n){
even += one[i] - 1;
odd--;
update(best , even , odd);
i++;
}
else if(even >= odd && j < n){
odd += two[j] - 1;
even--;
update(best , even , odd);
j++;
}
else break;
}
cout << setprecision(4) << fixed << best << '\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... |