#include <stdio.h>
#include <math.h>
#include <algorithm>
long long All[100005], Bll[100005];
int greater(long long a, long long b)
{
return (a > b);
}
int min(int a, int b)
{
return (a < b)?a:b;
}
int max(int a, int b)
{
return (a > b)?a:b;
}
long long min(long long a, long long b)
{
return (a < b)?a:b;
}
long long max(long long a, long long b)
{
return (a > b)?a:b;
}
int main()
{
int N;
scanf("%d", &N);
int i;
double A, B;
for (i = 0; i < N; i++)
{
scanf("%lf %lf", &A, &B);
All[i] = llround(A*10000.0);
Bll[i] = llround(B*10000.0);
// printf("%lld %lld\n", All[i], Bll[i]);
}
std::sort(All, All + N, greater);
std::sort(Bll, Bll + N, greater);
for (i = 1; i < N; i++)
{
// printf("%lld %lld ", All[i], Bll[i]);
All[i] += All[i - 1];
Bll[i] += Bll[i - 1];
// printf("(%lld %lld)\n", All[i], Bll[i]);
}
long long Ans = 0;
int mn, md, mx;
for (i = 2; i <= 2*N; i++)
{
mn = max(i - N - 1, 0);
mx = min(i - 2, N - 1);
// printf("%d %d\n", mn, mx);
while (mn != mx)
{
if (mx - mn == 1)
break;
md = (mn + mx)/2;
if (All[md] > Bll[i - 2 - md])
mx = md;
else
mn = md;
}
Ans = max(Ans, min(All[mx], Bll[i - 2 - mx]) - 10000LL*i);
Ans = max(Ans, min(All[mn], Bll[i - 2 - mn]) - 10000LL*i);
// printf("%lld\n", Ans);
}
printf("%lld.%04lld", Ans/10000LL, Ans%10000LL);
}
Compilation message
sure.cpp: In function 'int main()':
sure.cpp:28:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &N);
^
sure.cpp:33:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lf %lf", &A, &B);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Correct |
1 ms |
352 KB |
Output is correct |
3 |
Correct |
1 ms |
404 KB |
Output is correct |
4 |
Correct |
1 ms |
476 KB |
Output is correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
1 ms |
532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Correct |
1 ms |
352 KB |
Output is correct |
3 |
Correct |
1 ms |
404 KB |
Output is correct |
4 |
Correct |
1 ms |
476 KB |
Output is correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
1 ms |
532 KB |
Output is correct |
7 |
Correct |
2 ms |
532 KB |
Output is correct |
8 |
Correct |
1 ms |
532 KB |
Output is correct |
9 |
Correct |
2 ms |
532 KB |
Output is correct |
10 |
Correct |
1 ms |
532 KB |
Output is correct |
11 |
Correct |
1 ms |
532 KB |
Output is correct |
12 |
Correct |
2 ms |
532 KB |
Output is correct |
13 |
Correct |
2 ms |
532 KB |
Output is correct |
14 |
Correct |
2 ms |
620 KB |
Output is correct |
15 |
Correct |
2 ms |
620 KB |
Output is correct |
16 |
Correct |
2 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Correct |
1 ms |
352 KB |
Output is correct |
3 |
Correct |
1 ms |
404 KB |
Output is correct |
4 |
Correct |
1 ms |
476 KB |
Output is correct |
5 |
Correct |
2 ms |
532 KB |
Output is correct |
6 |
Correct |
1 ms |
532 KB |
Output is correct |
7 |
Correct |
2 ms |
532 KB |
Output is correct |
8 |
Correct |
1 ms |
532 KB |
Output is correct |
9 |
Correct |
2 ms |
532 KB |
Output is correct |
10 |
Correct |
1 ms |
532 KB |
Output is correct |
11 |
Correct |
1 ms |
532 KB |
Output is correct |
12 |
Correct |
2 ms |
532 KB |
Output is correct |
13 |
Correct |
2 ms |
532 KB |
Output is correct |
14 |
Correct |
2 ms |
620 KB |
Output is correct |
15 |
Correct |
2 ms |
620 KB |
Output is correct |
16 |
Correct |
2 ms |
620 KB |
Output is correct |
17 |
Correct |
86 ms |
2260 KB |
Output is correct |
18 |
Correct |
90 ms |
2260 KB |
Output is correct |
19 |
Correct |
87 ms |
2260 KB |
Output is correct |
20 |
Correct |
91 ms |
2260 KB |
Output is correct |
21 |
Correct |
89 ms |
2260 KB |
Output is correct |
22 |
Correct |
91 ms |
2260 KB |
Output is correct |
23 |
Correct |
104 ms |
2260 KB |
Output is correct |
24 |
Correct |
89 ms |
2260 KB |
Output is correct |
25 |
Correct |
99 ms |
2260 KB |
Output is correct |
26 |
Correct |
116 ms |
2260 KB |
Output is correct |