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;
typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"
const int N = 1e5;
double a[1 + N], b[1 + N];
int main () {
ios::sync_with_stdio (false);
cin.tie (0); cout.tie (0);
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i] >> b[i];
sort (a + 1, a + n + 1);
reverse (a + 1, a + n + 1);
sort (b + 1, b + n + 1);
reverse (b + 1, b + n + 1);
double suma = 0, sumb = 0;
double ans = 0;
int cura = 0, curb = 0;
for (int i = 1; i <= n * 2; i++) {
if ((suma < sumb || curb == n) && cura != n)
suma += a[++cura];
else
sumb += b[++curb];
ans = max (ans, min (suma, sumb) - i);
}
cout << fixed << setprecision (4) << ans << "\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... |