#include <bits/stdc++.h>
#include <sstream>
#include <fstream>
#define et "\n"
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ioi ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define M 1000000007
using namespace std;
ll n,m,k;
string s1;
map <ll,ll> mp;
double ans,cnt,cnt1;
double a[211111],b[211111],c[211111],c1 = 0;
void solve() {
cin >> n;
ans = 0;
for (int i = 1;i <= n;i++) {
cin >> a[i] >> b[i];
a[i] = -a[i];
b[i] = -b[i];
}
sort(a + 1,a + n + 1);
sort(b + 1,b + n + 1);
for (int i = 1;i <= n;i++) {
a[i] = -a[i];
b[i] = -b[i];
}
for (int i = 1;i <= n;i++) {
c[i] = b[i] + c[i - 1];
}
cnt = 0;
cnt1 = 0;
for (int i = 1;i <= n;i ++) {
c1 = i;
cnt += a[i];
ll l = 1,r = n;
while (l <= r) {
ll tm = (l + r) >> 1;
// cout << ans << ' ' << l << ' ' << r << ' ' << a[i] << ' ' << cnt << ' ' << c[tm] << et;
ans = max(ans,min(c[tm] - c1 - tm,cnt - c1 - tm));
if (cnt > c[tm]) {
if (b[tm] > 1) {
l = tm + 1;
}
else {
r = tm - 1;
}
}
else {
r = tm - 1;
}
}
}
printf("%.4lf",(double)ans);
}
int main() {
ioi;
ll tt = 1;
// cin >> tt;
while (tt--) {
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4440 KB |
Output is correct |
17 |
Correct |
62 ms |
4688 KB |
Output is correct |
18 |
Correct |
63 ms |
5716 KB |
Output is correct |
19 |
Correct |
64 ms |
5740 KB |
Output is correct |
20 |
Correct |
62 ms |
5572 KB |
Output is correct |
21 |
Correct |
70 ms |
5564 KB |
Output is correct |
22 |
Correct |
63 ms |
5584 KB |
Output is correct |
23 |
Correct |
62 ms |
5716 KB |
Output is correct |
24 |
Correct |
64 ms |
5976 KB |
Output is correct |
25 |
Correct |
63 ms |
5564 KB |
Output is correct |
26 |
Correct |
65 ms |
5584 KB |
Output is correct |