#include <bits/stdc++.h>
using namespace std;
bool ord(long double a, long double b){
return a > b;
}
int main(){
int n; cin >> n;
vector <long double> f(n), s(n);
for(int i = 0; i<n; i++) cin >> f[i] >> s[i];
sort(f.begin(), f.end(), ord);
sort(s.begin(), s.end(), ord);
long double ans = 0, i = 0, j = 0, si = 0, sj = 0;
if(f[i] > s[i]){
i = 1;
si += f[0];
}else{
j = 1;
sj += s[0];
}
ans = max(ans, min(sj, si) - (i+j));
while(i < n && j < n){
if(sj < si){
sj += s[j];
j++;
}else{
si += f[i];
i++;
}
ans = max(ans, min(sj, si) - (i+j));
}
cout.precision(4);
cout.setf(ios::fixed);
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |