#include<stdio.h> #include<algorithm> #include<math.h> using namespace std; const int MAX_N = 1000; int n, k, dist[MAX_N + 2]; double x[MAX_N + 2], y[MAX_N + 2]; bool f(int l) { fill(dist + 1, dist + n + 2, 0x7fffffff); int q[MAX_N + 2], h = 0, t = 0; q[t++] = 0; while (h != t) { for (int i = 0; i <= n + 1; i++) { if (dist[i] == 0x7fffffff && ceil(sqrt((x[i] - x[q[h]])*(x[i] - x[q[h]]) + (y[i] - y[q[h]])*(y[i] - y[q[h]])) / 10) <= l) { dist[i] = dist[q[h]] + 1; q[t++] = i; } } h++; } return dist[n + 1] <= k + 1; } int main() { scanf("%d %d", &n, &k); for (int i = 1; i <= n; i++) scanf("%lf %lf", &x[i], &y[i]); x[n + 1] = y[n + 1] = 10000; int h = 1, t = 1000, m; while (h <= t) { m = (h + t) / 2; if (f(m)) t = m - 1; else h = m + 1; } printf("%d", h); return 0; }
2585번: 경비행기
https://www.acmicpc.net/problem/2585
피드 구독하기:
댓글
(
Atom
)
댓글 없음 :
댓글 쓰기