Codeforces Round 438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)
B
Race Against Time
Codeforces
1400
原题
← AC →
翻译中…

Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time paradox! Space and time replaced each other.

翻译中…

The entire universe turned into an enormous clock face with three hands — hour, minute, and second. Time froze, and clocks now show the time $*h*$ hours, $*m*$ minutes, $*s*$ seconds.

翻译中…

Last time Misha talked with the coordinator at $*t*_{1}$ o'clock, so now he stands on the number $*t*_{1}$ on the clock face. The contest should be ready by $*t*_{2}$ o'clock. In the terms of paradox it means that Misha has to go to number $*t*_{2}$ somehow. Note that he doesn't have to move forward only: in these circumstances time has no direction.

翻译中…

Clock hands are very long, and Misha cannot get round them. He also cannot step over as it leads to the collapse of space-time. That is, if hour clock points 12 and Misha stands at 11 then he cannot move to 1 along the top arc. He has to follow all the way round the clock center (of course, if there are no other hands on his way).

翻译中…

Given the hands' positions, $*t*_{1}$, and $*t*_{2}$, find if Misha can prepare the contest on time (or should we say on space?). That is, find if he can move from $*t*_{1}$ to $*t*_{2}$ by the clock face.

翻译中…

Input

翻译中…

Five integers $*h*$, $*m*$, $*s*$, $*t*_{1}$, $*t*_{2}$ ($1 ≤ *h* ≤ 12$, $0 ≤ *m*, *s* ≤ 59$, $1 ≤ *t*_{1}, *t*_{2} ≤ 12$, $*t*_{1} ≠ *t*_{2}$).

翻译中…

Misha's position and the target time do not coincide with the position of any hand.

翻译中…

Output

翻译中…

Print "YES" (quotes for clarity), if Misha can prepare the contest on time, and "NO" otherwise.

翻译中…

You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES").

翻译中…

Note

翻译中…

The three examples are shown on the pictures below from left to right. The starting position of Misha is shown with green, the ending position is shown with pink. Note that the positions of the hands on the pictures are not exact, but are close to the exact and the answer is the same.

翻译中…

image

翻译中…

样例

Input #1
12 30 45 3 11
Output #1
NO
InputCopy OutputCopy
Input #2
12 0 1 12 1
Output #2
YES
InputCopy OutputCopy
Input #3
3 47 0 4 9
Output #3
YES
InputCopy OutputCopy
题目信息
题号
868B
时间限制
2 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。