#K57252. Longest Sequence of Attendable Events
Longest Sequence of Attendable Events
Longest Sequence of Attendable Events
You are given a set of N points on a 2D plane and a maximum allowable distance D. Each point represents the location of an event. You want to attend as many events as possible, but you can only move to an event if it is at most D units away from the previous event you attended.
Formally, you are given an integer \(N\) and an integer \(D\) along with a list of \(N\) points \( (x_i, y_i) \). Determine the maximum length of a sequence \( \{p_1, p_2, \ldots, p_k\} \) such that for every consecutive pair \( (p_i, p_{i+1}) \), the Euclidean distance satisfies \( \sqrt{(x_{p_i} - x_{p_{i+1}})^2 + (y_{p_i} - y_{p_{i+1}})^2} \leq D \).
inputFormat
The input is given via standard input (stdin).
The first line contains two integers (N) and (D), where (N) is the number of events and (D) is the maximum allowed distance between consecutive events. The following (N) lines each contain two space-separated integers representing the coordinates (x) and (y) of an event.
outputFormat
Output a single integer on standard output (stdout) representing the maximum number of events that can be attended consecutively.## sample
5 5
0 0
1 1
2 2
3 3
10 10
4