You all may hear about the USS (United States of Santosh). There is an office in the USS that consist of floors. The name of that office is USS-Economic Office.
Nafisa is an employee of the USS Economic Office. Her apartment is located on floor and she needs to go to the floor using the elevator. There's only one elevator in this office.
The initial position of the elevator is . The elevator takes 1 unit of time to move from one floor to another (upward or downward). For example, it will take 3 unites of time to move from 3rd floor to 6th floor.
If then the elevator is moving upward.
if then the elevator is moving downward.
While moving the elevator, it will open its door on each floor, and the time required for this is so small that we can omit it.
Someone has accidentally pressed buttons on the elevator . Now the buttons have stopped working. So Nafisa cannot press any more buttons, she can not change the order either. So it will carry out the pressed sequence only. So the lift will move from floor to floor , and then from floor to floor and so on.
Now,
If floor lies between and (inclusive) then It will take her from floor.
If floor lies between and (inclusive) and Nafisa already in the elevator then it will leave her to the floor.
You can assume it takes 0 units of time to get on and off the elevator.
You have to find out if it is possible to reach the floor. If it is possible then what is the time required to reach the floor?
NOTE: You can assume that the time starts when the elevator starts moving from the initial floor and Nafisa has been waiting on the floor from the beginning of the time.
Input will contain ( ), which is the number of calls that someone accidentally pressed.
The next line will be a sequence of number of floors , , ….., ( ).
The next line will be and , where is Nafisa's floor and is the floor that she wants to reach.
If Nafisa can reach floor from floor then print YES and the time required to reach floor.
Otherwise, print NO.
Input | Output |
---|---|
5 2 7 3 5 10 4 2 | NO |
Here is 4 is . While moving from floor to floor Nafisa will get into the elevator but after that, the elevator does not reach floor. So the answer is NO. |
Input | Output |
---|---|
5 5 12 3 7 4 4 3 | YES 16 |
Here is and is . While moving the elevator from the floor to the floor Nafisa will get into the elevator and after that as soon as the elevator reaches to floor she will get off. |
Input | Output |
---|---|
2 1 10 3 4 | YES 3 |
Input | Output |
---|---|
2 1 15 4 3 | NO |