#include <bits/stdc++.h>
using namespace std;
long long a[100005], b[100005], suma[100005], sumb[100005];
long long f(long long x, long long y)
{
return min(suma[x]-y*10000, sumb[y]-x*10000);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, ans=0;
cin >> n;
for (long long i=1; i<=n; i++)
{
double x, y;
cin >> x >> y;
a[i]=x*10000.0-9999.9;
b[i]=y*10000.0-9999.9;
}
sort(a+1, a+n+1, greater<long long>());
sort(b+1, b+n+1, greater<long long>());
for (long long i=1; i<=n; i++)
suma[i]=suma[i-1]+a[i];
for (long long i=1; i<=n; i++)
sumb[i]=sumb[i-1]+b[i];
for (long long i=0; i<=n; i++)
{
long long l=0, r=n;
while (l<r)
{
long long mid1=(l*2+r)/3, mid2=(l+r*2+1)/3;
long long res1=f(i, mid1), res2=f(i, mid2);
if (res1>res2)
r=mid2-1;
else if (res1<res2)
l=mid1+1;
else
{
l=mid1;
r=mid2-1;
}
}
ans=max(ans, f(i, l));
}
cout << fixed << setprecision(4) << ans/10000.0;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
83 ms |
4684 KB |
Output is correct |
18 |
Correct |
82 ms |
4784 KB |
Output is correct |
19 |
Correct |
91 ms |
4684 KB |
Output is correct |
20 |
Correct |
82 ms |
4788 KB |
Output is correct |
21 |
Correct |
86 ms |
5132 KB |
Output is correct |
22 |
Correct |
81 ms |
4816 KB |
Output is correct |
23 |
Correct |
77 ms |
4808 KB |
Output is correct |
24 |
Correct |
80 ms |
4816 KB |
Output is correct |
25 |
Correct |
78 ms |
4764 KB |
Output is correct |
26 |
Correct |
84 ms |
5164 KB |
Output is correct |