이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <functional>
#define MAXN 100100
double a[MAXN];
double b[MAXN];
double pa[MAXN];
double pb[MAXN];
int n;
int main(void) {
double best = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++) {
scanf("%lf %lf", &a[i], &b[i]);
}
std::sort(a, a + n, std::greater<double>());
std::sort(b, b + n, std::greater<double>());
std::partial_sum(a, a + n, pa);
std::partial_sum(b, b + n, pb);
for(int i = 0; i < n; i++) {
double x = pa[i];
double y1 = 0, y2 = 0;
auto it = std::upper_bound(pb, pb + n, x);
if(it != pb + n) y1 = std::min(x, *it) - std::distance(pb, it) - i - 2;
if(it != pb) it = std::prev(it);
y2 = std::min(x, *it) - std::distance(pb, it) - i - 2;
best = std::max(best, std::max(y1, y2));
}
printf("%.4lf", best);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
sure.cpp: In function 'int main()':
sure.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
sure.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%lf %lf", &a[i], &b[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |