# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
485386 |
2021-11-07T14:51:27 Z |
rainboy |
Kosta (COI14_kosta) |
C |
|
89 ms |
4520 KB |
#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
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 |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
2824 KB |
Output is correct |
2 |
Correct |
40 ms |
2932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
4520 KB |
Output is correct |
2 |
Correct |
85 ms |
4420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
1216 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |