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 <algorithm>
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const int NMAX = 1e5;
int n;
double res, s1, s2;
double a[1 + NMAX];
double b[1 + NMAX];
int main()
{
ios::sync_with_stdio(false);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i] >> b[i];
sort(a + 1, a + n + 1);
sort(b + 1, b + n + 1);
int i = n;
int j = n;
while(i >= 0 && j >= 0) {
if(s1 < s2) {
s1 += a[i];
i--;
} else {
s2 += b[j];
j--;
}
res = max(min(s1, s2) - 2 * n + i + j, res);
}
cout << setprecision(4) << fixed;
cout << res << '\n';
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... |