Hide

# Other Side

Indiana Dunes State Park. Image by pixabay.

John Doe wants to transport his possessions from one bank of Lake Michigan to the other. His possessions consist of $W$ wolves, $S$ sheep, and $C$ cabbages. The transportation will be carried out using a boat that can hold up to $K$ of these items at the same time. During each step, John can take some items from one bank and transfer them to the other bank. Unfortunately, when left unsupervised, wolves will eat sheep and sheep will eat cabbages (but wolves don’t eat cabbages). John doesn’t want to lose his possessions, so he has to devise a scheme such that this doesn’t happen. With John present, any combination of items is allowed (both on the bank and in the boat). This is also true during the loading process. Since John isn’t very good at solving problems like this, he asks you to help him.

## Input

Input contains a single line with four integers: $W$, $S$, $C$, $K$. The input satisfies the following constraints:

$0 \leq W, S, C, K \leq 10^6,$$1 \leq max(W, S, C).$

## Output

If it’s possible to perform the transportation without the loss of items, print YES, otherwise print NO.

Sample Input 1 Sample Output 1
1 1 1 1

YES

Sample Input 2 Sample Output 2
2 2 0 1

NO

CPU Time limit 1 second
Memory limit 1024 MB
Statistics Show
Downloads
Author
License

Please log in to submit a solution to this problem