#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<pair<double, double>> v1, v2;
for(int i=0;i<n;i++) {
double x, y;
cin >> x >> y;
v1.pb({-x, -y});
v2.pb({-y, -x});
}
sort(all(v1));
sort(all(v2));
vector<double> pre1, pre2;
for(int i=0;i<n;i++) {
pre1.pb(-v1[i].st+(i?pre1[i-1]:0));
pre2.pb(-v2[i].st+(i?pre2[i-1]:0));
}
double ans = 0;
for(int i=0;i<n;i++) {
int s = -1;
int e = n;
while(e-s>1) {
int m = (e+s)/2;
if(pre2[m]>=pre1[i]) e = m;
else s = m;
}
if(e == n) continue;
ans = max(ans, pre1[i]-i-1-e-1);
}
for(int i=0;i<n;i++) {
int s = -1;
int e = n;
while(e-s>1) {
int m = (e+s)/2;
if(pre1[m]>=pre2[i]) e = m;
else s = m;
}
if(e == n) continue;
ans = max(ans, pre2[i]-i-1-e-1);
}
printf("%.4lf",(double)ans);
cout << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 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 |
320 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 |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 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 |
320 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 |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
100 ms |
7704 KB |
Output is correct |
18 |
Correct |
98 ms |
6460 KB |
Output is correct |
19 |
Correct |
94 ms |
6420 KB |
Output is correct |
20 |
Correct |
93 ms |
6312 KB |
Output is correct |
21 |
Correct |
93 ms |
6344 KB |
Output is correct |
22 |
Correct |
93 ms |
6448 KB |
Output is correct |
23 |
Correct |
94 ms |
6352 KB |
Output is correct |
24 |
Correct |
95 ms |
6312 KB |
Output is correct |
25 |
Correct |
111 ms |
6304 KB |
Output is correct |
26 |
Correct |
108 ms |
6380 KB |
Output is correct |