ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

USU Junior Championship. March 2001

About     Problems     Submit solution     Judge status     Standings
Contest is over

G. Ilya Murometz

Time limit: 1.0 second
Memory limit: 64 MB
Misfortune has come to the Russian land. Foul Idol has dragged away good fellow Alyosha Popovich and has chained him with iron chains to the magical stone, so that Alyosha canТt even step. It is necessary to rescue Alyosha from the captivity but nobody is able to: the Tsar is on the war with his detachment. Ilya Murometz has thought a bit and says: "I'll go to rescue my friend Alyosha from Foul Idol alone, and if he is to die there, so am I". Ilya has said these words, and has leaped on to his good horse and has gone seeking for Alyosha.
Ilya rides his horse and comes to a stone, but not the magic one that he has been looking for, but to the road stone. As usual, it is written there: "If you go left — you'll get `time limit', if you go right — you'll get `wrong answer'". Ilya Murometz sits down and falls apart. Suddenly a little bird sits near and asks: "Why are you upset, good fellow?" Ilya Murometz tells her about his problem and the bird tells him: "It's always here like this: if you go left — in an hour you'll see such road stone; and so until you come to the sea. Foul Idol has made this. He wants you to get lost here. Go home, Ilya Murometz, don't try your doom!" And the bird disappears, as there hasn't been the one. Ilya Murometz thinks a lot, but decides not to betray his friendship. He leaps on to his good horse and continues his way. And he rides, and he rides, and he rides.
Ilya Murometz dismounts near a road stone that is like the first one and falls apart more than the first time. Suddenly he sees the magic stone — it is close to him, but Ilya Murometz can't leave the road — he'll disappear in the marsh. He sees the sea very close to him — he can even count: there's D hours of the way from the magic stone to the sea, and from himself he'll have to ride E hours. But from his father he new that from the first stone to the sea (no matter where he turns) there's F hours way.
He looks closely and sees that the road leads to the moorings, and the moorings are enumerated with integers. Ilya looks very-very closely and he finds out that there is a rule of the enumeration: if one rides from the first stone always to the right — he comes to the mooring #1, if at the last moment one turns left — he comes to the mooring #2, and if one always turns right, one before the last time he turns left and then turns right — he comes to the mooring #3! Ilya Murometz sees, that the nearest mooring to his stone is #Ep, and the nearest one to the magic stone is #Dp. But the roads branch, and there are other moorings.
The good horse turns his head and tells to Ilya Murometz: "Ilyusha! I won't gallop more than H hours." Help to Ilya Murometz to find out, wether he saves Alyosha Popovich, or he stays himself in the foreign land.
Problem illustration

Input

The first line contains 6 integers: D, E, F, Dp, Ep, H. 0 ≤ D, E, F, H ≤ 30; 1 ≤ Ep, Dp ≤ 1 073 741 824. All numbers are separated with a space.

Output

should contain the word “YES”, if Ilya Murometz will reach Alyosha Popovich on his horse, and otherwise — the word “NO”.

Sample

inputoutput
1 2 3 2 6 4
YES
Problem Author: Oleg Katz
Problem Source: The 3rd high school children programming contest, USU, Yekaterinburg, Russia, March 4, 2001
To submit the solution for this problem go to the Problem set: 1088. Ilya Murometz