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>
//#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
signed main() {
int n; cin >> n;
vector<double> a(n), b(n);
for(int i=0; i<n; i++) cin >> a[i] >> b[i];
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
double ans = 0;
double sum1 = 0;
for(int i=0; i<n; i++) {
sum1 += a[i];
double sum2 = 0;
for(int j=0; j<n; j++) {
sum2 += b[j];
ans = max(ans, min(sum1 - (i + j + 2), sum2 - (i + j + 2)));
}
}
cout << setprecision(4) << fixed << 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... |