#include <bits/stdc++.h>
#define all(a) begin(a), end(a)
using namespace std;
void solve() {
int n;
cin >> n;
vector<double> v[2];
v[0].resize(n);
v[1].resize(n);
for (int i = 0; i < n; ++i) {
cin >> v[0][i] >> v[1][i];
}
sort(all(v[0]), greater<>());
sort(all(v[1]), greater<>());
double ans = 0;
double cur[2] = {0, 0};
int p = 0;
for (int i = 0; i < n; ++i) {
cur[0] += v[0][i] - 1;
cur[1] -= 1;
ans = max(ans, min(cur[0], cur[1]));
while (p < n && cur[1] < cur[0]) {
cur[1] += v[1][p] - 1;
cur[0] -= 1;
ans = max(ans, min(cur[0], cur[1]));
++p;
}
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(4);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
77 ms |
3256 KB |
Output is correct |
18 |
Correct |
77 ms |
3152 KB |
Output is correct |
19 |
Correct |
74 ms |
3148 KB |
Output is correct |
20 |
Correct |
91 ms |
3256 KB |
Output is correct |
21 |
Correct |
86 ms |
3628 KB |
Output is correct |
22 |
Correct |
76 ms |
3156 KB |
Output is correct |
23 |
Correct |
77 ms |
3252 KB |
Output is correct |
24 |
Correct |
77 ms |
3168 KB |
Output is correct |
25 |
Correct |
81 ms |
3148 KB |
Output is correct |
26 |
Correct |
89 ms |
3532 KB |
Output is correct |