#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
typedef long double ld;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<ld> A(n), B(n);
for (int i = 0; i < n; i++) {
ld a, b;
cin >> a >> b;
A.push_back(a-1.0);
B.push_back(b-1.0);
}
sort(A.begin(), A.end());
reverse(A.begin(), A.end());
sort(B.begin(), B.end());
reverse(B.begin(), B.end());
ld wynik = 0.0;
ld wynA = 0.0, wynB = 0.0;
int idxB = 0;
for (int i = 0; i < n; i++) {
wynik = max(wynik, min(wynA, wynB));
wynA += A[i];
wynB -= 1.0;
while (wynB <= wynA) {
wynB += B[idxB];
wynA -= 1.0;
idxB++;
}
}
wynik = max(wynik, min(wynA, wynB));
cout << fixed << setprecision(4) << wynik << '\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... |