#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
const int maxn5 = 1e6 + 10;
vector <double> av[2];
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n; cin >> n;
for(int i = 0; i < n; i++){
double a, b; cin >> a >> b;
av[0].pb(a);
av[1].pb(b);
}
sort(all(av[0])); reverse(all(av[0]));
sort(all(av[1])); reverse(all(av[1]));
for(int i = 1; i < n; i++){
av[0][i] += av[0][i - 1];
av[1][i] += av[1][i - 1];
}
double ans = 0;
for(int i = 0; i < n; i++){
int pt = lower_bound(all(av[0]), av[1][i]) - av[0].begin();
if(pt < n)
ans = max(ans, av[1][i] - i - pt - 2);
pt = lower_bound(all(av[1]), av[0][i]) - av[1].begin();
if(pt < n)
ans = max(ans, av[0][i] - i - pt - 2);
}
cout << setprecision(4) << fixed << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
324 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 |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
324 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 |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
324 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
336 KB |
Output is correct |
17 |
Correct |
88 ms |
3372 KB |
Output is correct |
18 |
Correct |
87 ms |
3432 KB |
Output is correct |
19 |
Correct |
86 ms |
3528 KB |
Output is correct |
20 |
Correct |
97 ms |
3480 KB |
Output is correct |
21 |
Correct |
91 ms |
3768 KB |
Output is correct |
22 |
Correct |
87 ms |
3476 KB |
Output is correct |
23 |
Correct |
101 ms |
3404 KB |
Output is correct |
24 |
Correct |
88 ms |
3504 KB |
Output is correct |
25 |
Correct |
92 ms |
3476 KB |
Output is correct |
26 |
Correct |
89 ms |
3920 KB |
Output is correct |