#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
#define int long long
int n, a[N], prea[N], b[N], preb[N];
signed main() {
cin.tie(0), cout.tie(0) -> sync_with_stdio(0);
cin >> n;
for (int i = 1; i <= n; i++) {
double x, y;
cin >> x >> y;
a[i] = (int) (x * 10000);
b[i] = (int) (y * 10000);
// cout << a[i] << b[i] << '\n';
}
sort(a + 1, a + n + 1);
sort(b + 1, b + n + 1);
reverse(a + 1, a + n + 1);
reverse(b + 1, b + n + 1);
vector<int> allp(1, 0);
for (int i = 1; i <= n; i++) {
prea[i] = prea[i - 1] + a[i];
preb[i] = preb[i - 1] + b[i];
allp.push_back(prea[i]);
allp.push_back(preb[i]);
}
sort(allp.begin(), allp.end());
allp.erase(unique(allp.begin(), allp.end()), allp.end());
int i = 0, j = 0, res = 0;
for (auto v : allp) {
while (i <= n && prea[i] < v) i ++;
while (j <= n && preb[j] < v) j ++;
if (i > n || j > n) break;
res = max(res, v - (i + j) * 10000);
}
double ans = res / 10000.0;
printf("%.4lf", ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |