이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#define N1 200000
#define N2 50000
#define INF 0x3f3f3f3f
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int xx[N1], yy[N1], n;
int t, u;
int check(int d) {
int i, xmn, xmx, ymn, ymx;
xmn = INF, xmx = -INF, ymn = INF, ymx = -INF;
for (i = 0; i < n; i++) {
xmn = min(xmn, xx[i]), xmx = max(xmx, xx[i]);
ymn = min(ymn, yy[i]), ymx = max(ymx, yy[i]);
}
u = -1;
for (i = 0; i < n; i++)
if (xx[i] - xmn <= d && xmx - xx[i] <= d && yy[i] - ymn <= d && ymx - yy[i] <= d) {
u = i;
return 1;
}
return 0;
}
int main() {
int i, lower, upper;
scanf("%d%d", &t, &n);
for (i = 0; i < n; i++) {
int x, y;
scanf("%d%d", &x, &y);
xx[i] = x + y, yy[i] = x - y;
}
lower = -1, upper = INF;
while (upper - lower > 1) {
int d = (lower + upper) / 2;
if (check(d))
upper = d;
else
lower = d;
}
check(upper);
printf("%d\n", upper);
printf("%d\n", u + 1);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
kosta.c: In function 'main':
kosta.c:34:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
34 | scanf("%d%d", &t, &n);
| ^~~~~~~~~~~~~~~~~~~~~
kosta.c:38:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
38 | scanf("%d%d", &x, &y);
| ^~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |