#include<bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
double arr[MAX], brr[MAX];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
for(int i = 1; i <= n; i ++) cin >> arr[i] >> brr[i];
sort(arr + 1, arr + 1 + n, greater<double>());
sort(brr + 1, brr + 1 + n, greater<double>());
double sA = 0, sB = 0, ans = 0;
int cA = 0, cB = 0;
for(int i = 1; max(cA, cB) < n; i ++)
{
if(sA < sB and cA < n)
{
cA ++;
sA += arr[cA];
}
else
{
cB ++;
sB += brr[cB];
}
ans = max(ans, min(sA, sB) - i);
}
cout << fixed << setprecision(4) << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |