2018 North Central NA Regional Contest


2018-11-03 16:00 UTC

2018 North Central NA Regional Contest


2018-11-03 21:00 UTC
The end is near!
Contest is over.
Not yet started.
Contest is starting in -141 days 8:01:20

Time elapsed


Time remaining


Problem I
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 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). \]


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
Sample Input 2 Sample Output 2
2 2 0 1