Wesley is running late to school!
The neighbourhood is modelled as a coordinate plane, and Wesley's house is currently sitting at
Being the cool kid that he is, Wesley does a lot of parkour and will use his abilities to move faster than most people. In one second, he can move in one of two ways:
- Move
metres up, then metre right - Move
metre up, then metres right
Hurry, the bell rings in
Note that Wesley can only enter the school if he touches an entrance to the school after performing a move.
Python users are recommended to use PyPy over CPython. There is a significant performance increase.
Input Specification
The first line of the input will contain four integers
The second line of the input will contain one integer
It is guaranteed that the school will not be located directly at Wesley's house and that it will be reachable using the moves described.
Output Specification
If Wesley can parkour in time to school (in strictly less than YES
. Otherwise, output NO
.
Constraints
Subtask 1 [30%]
Subtask 2 [70%]
No additional constraints.
Sample Input 1
2 3 3 3
2
Sample Output 1
NO
Explanation For Sample 1
While it is possible for Wesley to reach the school in
- Move
metre up, move metres right to - Move
metres up, move metre right to
The bell would ring by the time he gets there, making it impossible.
Sample Input 2
2 3 3 3
3
Sample Output 2
YES
Explanation For Sample 2
This time, Wesley has enough time to make it before the bell rings, making the trip now possible.
Comments
Damn, this problem is very difficult. I think it should be 7 points instead of 5.
What's test case #28?
My issue with case 28 is that I was counting a negative number of moves as valid, which obviously isn't possible.
Anyone know why my code doesn't work?
Not enough corner case testing.
If you do it by hand you can see it is in fact possible to get to school in this case by simply using 4 of one move and 3 of the other move.
Doesn't this bring him to either
or 
, neither of which are entrances?
Yeah oops I just got confused about the formal definition because my submission using the correct condition fails but my submission using the wrong condition works.
Can you explain how you would get to school in this case?
This is my favourite problem! Thanks Zeyu!
Happy to hear that, thanks :)