Sugan Loves Biriyani


Submit solution

Points: 3
Time limit: 5.0s
Memory limit: 256M

Author:
Problem type

Sugan loves biriyani. Unfortunately, he isn't able to find any restaurant near him. Nevertheless, he is ready to travel any distance to eat his favorite dish. The only factor than might stop him from reaching the restaurant is the amount of fuel his car has. An array 'x' determines the distance between consecutive bunks, through which he will have to travel through. If he happens to find a bunk on his way, he refuels his tank to its maximum capacity. The car can travel 'y' KM when the fuel tank is full. We need to find if Sugan can eventually reach the restaurant or not.

To make things simple, given an array, find the number of steps before which an element greater than 'y' is encountered.

Input Description:

The first line contains the number of test cases. For each test case, the first line of each testcase contains 'n', the number of petrol bunks between his starting point and the restaurant. The next line contains 'n' numbers from x1 up till xn, each of which are separated by space. The next line contains 'y'.

CONSTRAINTS

  • 1 ≤ T ≤ 10
  • 2 ≤ N ≤ 10^5
  • each element of the given list ≤ 10^3
  • y ≤ 10^3

Output Description:

For each testcase, print the answer in a new line.

If Sugan will be able to reach the restaurant, print 'YES'. If he isn't lucky enough, print 'NO' followed by the number of bunks that Sugan has visited until now.

Sample Input:

3
4
4 6 17 8
10
2
3 4
5
1 
100
200

Sample Output:

NO 2
YES
YES

Comments

There are no comments at the moment.