#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = (int) 1e9 + 1e6 + 123;
const ll LINF = (ll) 1e18 + 1e9 + 123;
#define rep(i, s, t) for (auto i = (s); i < (t); ++(i))
#define per(i, s, t) for (auto i = (s); i >= (t); --(i))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
bool mini(auto &x, const auto &y) {
if (y < x) {
x = y;
return 1;
}
return 0;
}
bool maxi(auto &x, const auto &y) {
if (y > x) {
x = y;
return 1;
}
return 0;
}
void run();
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
run();
return 0;
}
const int N = (int) 1e5 + 123;
int n;
ld a[N], b[N];
ld pa[N], pb[N];
void run() {
cin >> n;
rep(i, 1, n + 1) {
cin >> a[i] >> b[i];
}
sort(a + 1, a + n + 1);
reverse(a + 1, a + n + 1);
sort(b + 1, b + n + 1);
reverse(b + 1, b + n + 1);
rep(i, 1, n + 1) {
a[i] += a[i - 1];
b[i] += b[i - 1];
pa[i] = max(pa[i - 1], a[i] - i);
pb[i] = max(pb[i - 1], b[i] - i);
}
ld ans = 0;
rep(i, 0, n + 1) {
int r = (int) (upper_bound(b, b + n + 1, a[i]) - b - 1);
maxi(ans, pb[r] - i);
}
rep(i, 0, n + 1) {
int r = (int) (upper_bound(a, a + n + 1, b[i]) - a - 1);
maxi(ans, pa[r] - i);
}
cout << fixed << setprecision(4);
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
10 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
616 KB |
Output is correct |
6 |
Correct |
2 ms |
616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
10 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
616 KB |
Output is correct |
6 |
Correct |
2 ms |
616 KB |
Output is correct |
7 |
Correct |
2 ms |
616 KB |
Output is correct |
8 |
Correct |
2 ms |
616 KB |
Output is correct |
9 |
Correct |
2 ms |
616 KB |
Output is correct |
10 |
Correct |
2 ms |
616 KB |
Output is correct |
11 |
Correct |
2 ms |
616 KB |
Output is correct |
12 |
Correct |
3 ms |
692 KB |
Output is correct |
13 |
Correct |
3 ms |
692 KB |
Output is correct |
14 |
Correct |
3 ms |
692 KB |
Output is correct |
15 |
Correct |
3 ms |
692 KB |
Output is correct |
16 |
Correct |
3 ms |
692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
10 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
616 KB |
Output is correct |
6 |
Correct |
2 ms |
616 KB |
Output is correct |
7 |
Correct |
2 ms |
616 KB |
Output is correct |
8 |
Correct |
2 ms |
616 KB |
Output is correct |
9 |
Correct |
2 ms |
616 KB |
Output is correct |
10 |
Correct |
2 ms |
616 KB |
Output is correct |
11 |
Correct |
2 ms |
616 KB |
Output is correct |
12 |
Correct |
3 ms |
692 KB |
Output is correct |
13 |
Correct |
3 ms |
692 KB |
Output is correct |
14 |
Correct |
3 ms |
692 KB |
Output is correct |
15 |
Correct |
3 ms |
692 KB |
Output is correct |
16 |
Correct |
3 ms |
692 KB |
Output is correct |
17 |
Correct |
139 ms |
6796 KB |
Output is correct |
18 |
Correct |
139 ms |
8300 KB |
Output is correct |
19 |
Correct |
139 ms |
9628 KB |
Output is correct |
20 |
Correct |
158 ms |
11120 KB |
Output is correct |
21 |
Correct |
145 ms |
12740 KB |
Output is correct |
22 |
Correct |
136 ms |
14112 KB |
Output is correct |
23 |
Correct |
141 ms |
15544 KB |
Output is correct |
24 |
Correct |
141 ms |
16932 KB |
Output is correct |
25 |
Correct |
141 ms |
18260 KB |
Output is correct |
26 |
Correct |
147 ms |
20036 KB |
Output is correct |