#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n; cin>>n;
vector<double> a(n + 1), b(n + 1);
for (int i = 1; i <= n; i++){
cin>>a[i]>>b[i];
}
sort(a.begin() + 1, a.end(), greater<double>());
sort(b.begin() + 1, b.end(), greater<double>());
for (int i = 1; i <= n; i++){
a[i] += a[i - 1];
b[i] += b[i - 1];
}
double out = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
out = max(out, min(a[i], b[j]) - (i + j));
}
}
printf("%.4lf", out);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |