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 <iostream>
#include <algorithm>
#include <iomanip>
#define MAX 100000
using namespace std;
///ifstream cin ("c.in");
///ofstream cout ("c.out");
double a[MAX + 10], b[MAX + 10];
bool cmp(double x, double y)
{
return (x > y);
}
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i] >> b[i];
sort(a + 1, a + n + 1, cmp);
sort(b + 1, b + n + 1, cmp);
int nA = 1, nB = 1;
double A = 0, B = 0, ans = 0;
for (int i = 1; i <= 2 * n; i++)
{
if (nA <= n && (nB == n + 1 || A < B))
{
A = A + a[nA];
nA++;
}
else
{
B = B + b[nB];
nB++;
}
ans = max(ans, min(A, B) - i);
}
cout << fixed << setprecision(4) << ans;
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... |