This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (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... |