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;
const int MAX = 2e5 + 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; i <= 2 * n; i ++)
{
if(sA < sB)
{
cA ++;
sA += arr[cA];
}
else
{
cB ++;
sB += brr[cB];
}
ans = max(ans, min(sA, sB) - i);
}
cout << fixed << setprecision(4) << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |