Codeforce 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.






题意:
输入时、分、秒和两个表示小时的点,问时针、分针和秒针分成的三个区间有没有使得两个点在同一个区间。

思路:
首先把三个针指的数变成表上的数(小数),从小到大排序
对于1~12的区间正常判断
对于最大值和最小值,若在他们之间则是“YES”

代码:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

bool pd(double l,double r,double a,double b)
{
    if( (a>=l&&a<=r) && (b>=l&&b<=r))return 1;
    return 0;
}

int main()
{
    double h,s,m,a,b;
    cin>>h>>s>>m>>a>>b;
    if(a>b)swap(a,b);
    if(s!=0 || m!=0)
        h+=0.1;
    
    s=s*1.0/60*12;
    if(m!=0)
        s+=0.1;
    
    m=m*1.0/60*12;
    
    double p[5]={h,s,m};
    sort(p,p+3);
    
    int f=0;
    for(int i=0;i<2;i++)
        if(pd(p[i],p[i+1],a,b))
            f=1;
    
    if( (a<=p[0]&&b>=p[2]) || (a>=p[2] && b>=p[2]) || (a<=p[0]&& b<=p[0]))
        f=1;
    
    cout<< (f==1?"YES":"NO") <<endl;
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值