#K49772. Can Visit All Cities

    ID: 28717 Type: Default 1000ms 256MiB

Can Visit All Cities

Can Visit All Cities

You are given a series of test cases. Each test case specifies a group of cities aligned along a route, a mileage limit \(L\), and the distances between consecutive cities. For each test case, your task is to determine if the total distance needed to visit all cities is within the mileage limit.

Formally, you are given an integer \(N\) (number of cities) and a mileage limit \(L\). Then you are provided with \(N-1\) integers representing the distances between consecutive cities. If the sum of these distances is less than or equal to \(L\), output YES; otherwise, output NO.

Input Format: The first line contains an integer \(T\), the number of test cases. For each test case, the first line contains two integers \(N\) and \(L\), followed by a line with \(N-1\) space-separated integers representing the distances.

Output Format: For each test case, output a single line containing YES if the total distance is within the mileage limit, or NO otherwise.

inputFormat

The input begins with an integer \(T\), the number of test cases. Each test case has the following format:

  • The first line contains two integers \(N\) (number of cities) and \(L\) (mileage limit).
  • The second line contains \(N-1\) space-separated integers representing the distances between consecutive cities.

All numbers are separated by spaces and/or newlines.

outputFormat

For each test case, output a single line containing YES if the sum of the distances does not exceed \(L\), or NO if it exceeds \(L\).

## sample
2
5 100
10 20 30 20
4 50
15 20 25
YES

NO

</p>