이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |