#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));
double ans = 0;
double sum1 = 0;
int cur = 0;
double sum2 = 0;
for(int i=0;i<=n;i++) {
if(i) sum1 -= v1[i-1].st;
while(cur!=n-1&&min(sum1, sum2-v2[cur].st)-i-cur-1>min(sum1, sum2)-i-cur) {
sum2-=v2[cur].st;
cur++;
}
ans = max(ans, min(sum1, sum2)-i-cur);
}
printf("%.4lf",(double)ans);
cout << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |