Other Side
Time limit2sMemory limit512 MB
- Level
Not classified yet
- Solved
- No attempts yet
Problem
John Doe wants to move his possessions from one bank of Lake Michigan to the other. He has W wolves, S sheep, and C cabbages. A boat that holds up to K of these items at once carries them across. In each step, John takes some items from one bank and moves them to the other bank. When left unsupervised, wolves eat sheep and sheep eat cabbages (wolves do not eat cabbages). John does not want to lose any possessions, so he needs a plan that prevents this. With John present, any combination of items is allowed, both on the banks and in the boat. This also holds during loading. John is not very good at problems like this, so he asks you for help.
Input
The input is a single line with four integers W, S, C, K. The input satisfies the following constraints:
Output
If the transportation can be done without losing any items, print YES. Otherwise, print NO.