#K69687. Platform Reachability Problem
Platform Reachability Problem
Platform Reachability Problem
Given a track of length \(L\) and a collection of \(n\) step sizes, determine whether it is possible to reach exactly the end of the track by using any combination of these steps. You may use each step any number of times. Formally, the task is to decide if there exist non-negative integers \(a_1, a_2, \dots, a_n\) such that
\(a_1 \times step_1 + a_2 \times step_2 + \dots + a_n \times step_n = L\)
If such a combination exists, print YES; otherwise, print NO.
inputFormat
The input consists of two lines:
- The first line contains two space-separated integers: \(n\) (the number of available step sizes) and \(L\) (the target length of the track).
- The second line contains \(n\) space-separated integers representing the step sizes.
Formally, find non-negative integers \(a_1, a_2, \dots, a_n\) such that \(a_1 \times step_1 + \dots + a_n \times step_n = L\).
outputFormat
Output a single line containing YES if it is possible to exactly reach the target length \(L\) by summing multiples of the given steps; otherwise, output NO.
## sample3 5
1 2 3
YES