Other Side
시간 제한2초메모리 제한512 MB
배에 K개까지 실을 수 있을 때, 늑대 W마리, 양 S마리, 양배추 C개를 먹힘 없이 강 건너로 옮길 수 있는지 판정한다.
문제
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 ≤ W, S, C, K ≤ 106,
- 1 ≤ max(W, S, C).
출력
If it’s possible to perform the transportation without the loss of items, print YES, otherwise print NO.