#include <bits/stdc++.h>
using namespace std;
//#define int long long
const int N = 1e5;
int n;
double f[N + 5], se[N + 5], prefix[N + 5];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++) cin >> f[i] >> se[i];
sort(f + 1, f + n + 1, greater<double>());
sort(se + 1, se + n + 1, greater<double>());
for (int i = 1; i <= n; i++) prefix[i] = max(prefix[i - 1], se[i] - (double)i);
double l = -1e18, r = 1e18, ans = -1e18;
const double eps = 1e-9;
while (r - l > eps) {
double m = (l + r)/2.0, fValue = 0.0;
bool valid = false;
for (int i = 0; i <= n; i++) {
fValue += f[i];
int rem = min(n, (int)floor(fValue - m) - i);
if(rem < 0) continue;
valid |= prefix[rem] - (double)i > m || abs(prefix[rem] - (double)i - m) < eps;
}
if (valid) ans = m, l = m;
else r = m;
}
cout << fixed << setprecision(4) << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |