이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
컴파일 시 표준 에러 (stderr) 메시지
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);
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |