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 endl '\n'
using namespace std;
int main(){
ios::sync_with_stdio(false); cin.tie(NULL);
int n; cin >> n;
vector<double> l(n), r(n);
for(int i = 0; i < n; i++)
cin >> l[i] >> r[i];
sort(l.begin(), l.end()); sort(r.begin(), r.end());
reverse(l.begin(), l.end()); reverse(r.begin(), r.end());
int q1 = 1, q2 = 1;
double s1 = l[0], s2 = r[0];
double maior = max((double)0, min(s1 - 2, s2 - 2));
while(true){
if(s1 < s2){
if(q1 >= n || l[q1] == 1) break;
s1 += l[q1];
q1++;
}else{
if(q2 >= n || r[q2] == 1) break;
s2 += r[q2];
q2++;
}
maior = max(maior, min(s1 - (q1+q2), s2 - (q1+q2)));
}
cout.precision(4);
cout << fixed;
cout << maior << endl;
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... |