codeforces 868B

B. Race Against Time
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 t1 o'clock, so now he stands on the number t1 on the clock face. The contest should be ready by t2 o'clock. In the terms of paradox it means that Misha has to go to number t2 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, t1, and t2, find if Misha can prepare the contest on time (or should we say on space?). That is, find if he can move from t1 to t2 by the clock face.

Input

Five integers h, m, s, t1, t2 (1 ≤ h ≤ 12, 0 ≤ m, s ≤ 59, 1 ≤ t1, t2 ≤ 12, t1 ≠ t2).

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").

Examples
Input
12 30 45 3 11
Output
NO
Input
12 0 1 12 1
Output
YES
Input
3 47 0 4 9
Output
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.

 

 

说出来你们可能不信,这题到最后我都没做出来。

因为我没根本没有想到,秒针分针时针三个是联动的T T。

(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.主要是这句话误导了我,我以为这句话就是为了强调其实图中的针和刻度是一致的,不用考虑三者的联动)

附事后ac代码:

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <iostream>
 4 #include <string>
 5 #include <algorithm>
 6 #include <cmath>
 7 using namespace std;
 8 double nu[5];
 9 int main() {
10     ios::sync_with_stdio(false);
11     for(int i = 0; i < 5; i++) {
12         cin>>nu[i];
13         if(i==0||i==3||i==4) nu[i]*=5;
14         if(nu[i]==60) nu[i]=0;
15     }
16     nu[1]+=nu[2]/60;
17     nu[0]+=nu[1]/60;
18     double t1 = min(nu[3],nu[4]);
19     double t2 = max(nu[3],nu[4]);
20     int flag =0;
21     for(int i = 0; i < 3; i++) {
22         if(nu[i] > t1 && nu[i] < t2) flag++;
23         
24     }
25     if(flag==3 || flag==0) cout<<"YES"<<endl;
26     else cout<<"NO"<<endl;
27     
28     return 0;
29 }
View Code

 

 

posted @ 2017-10-05 23:18  euzmin  阅读(145)  评论(0编辑  收藏  举报