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;
using ll = long long;
/*
* max(min(Sum_{1 to n} of ai or -1,
* Sum_{1 to n} of bi or -1))
*
*/
const int maxn = 1e5+5;
int n;
double a[maxn], b[maxn];
int main()
{
//ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
}
sort(a+1,a+1+n,greater<double>());
sort(b+1,b+1+n,greater<double>());
for (int i = 2; i <= n; i++) {
a[i] += a[i-1];
b[i] += b[i-1];
//cout << a[i] << ' ' << b[i] << '\n';
}
double maxans = 0;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n; j++) {
double aa = a[i] - i - j;
double bb = b[j] - j - i;
//cout << min(aa,bb) << '\n';
maxans = max(maxans,min(aa,bb));
}
}
printf("%.4lf\n",(double)maxans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |