#include <bits/stdc++.h>
using namespace std;
#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;
const int MXN = 100005;
int n;
double a[MXN], b[MXN];
double p[MXN], q[MXN];
double calc(int i) {
int l = 0, r = n + 1;
while (l + 1 < r) {
int mid = (l + r) >> 1;
((p[i] - mid >= q[mid] - i) ? l : r) = mid;
}
return max(min(p[i] - l, q[l] - i), min(p[i] - r, q[r] - i));
}
void miku() {
cin >> n;
FOR(i, 0, n) cin >> a[i] >> b[i];
sort(a, a + n, greater<double>());
sort(b, b + n, greater<double>());
FOR(i, 0, n) p[i + 1] = p[i] + a[i] - 1;
FOR(i, 0, n) q[i + 1] = q[i] + b[i] - 1;
double ans = 0.0;
FOR(i, 1, n + 1) ans = max(ans, calc(i));
cout << fixed << setprecision(4) << ans << '\n';
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin.exceptions(cin.failbit);
miku();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
2 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
2 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
2 ms |
2392 KB |
Output is correct |
13 |
Correct |
2 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
2 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
2 ms |
2392 KB |
Output is correct |
13 |
Correct |
2 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2392 KB |
Output is correct |
17 |
Correct |
73 ms |
4760 KB |
Output is correct |
18 |
Correct |
65 ms |
4812 KB |
Output is correct |
19 |
Correct |
69 ms |
4936 KB |
Output is correct |
20 |
Correct |
68 ms |
4696 KB |
Output is correct |
21 |
Correct |
75 ms |
5068 KB |
Output is correct |
22 |
Correct |
68 ms |
4700 KB |
Output is correct |
23 |
Correct |
64 ms |
4944 KB |
Output is correct |
24 |
Correct |
65 ms |
4688 KB |
Output is correct |
25 |
Correct |
81 ms |
4760 KB |
Output is correct |
26 |
Correct |
79 ms |
5208 KB |
Output is correct |