103520: [Atcoder]ABC352 A - AtCoder Line

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:10 Solved:0

Description

Score: $100$ points

Problem Statement

The AtCoder railway line has $N$ stations, numbered $1, 2, \ldots, N$.

On this line, there are inbound trains that start at station $1$ and stop at the stations $2, 3, \ldots, N$ in order, and outbound trains that start at station $N$ and stop at the stations $N - 1, N - 2, \ldots, 1$ in order.

Takahashi is about to travel from station $X$ to station $Y$ using only one of the inbound and outbound trains.

Determine whether the train stops at station $Z$ during this travel.

Constraints

  • $3 \leq N \leq 100$
  • $1 \leq X, Y, Z \leq N$
  • $X$, $Y$, and $Z$ are distinct.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

$N$ $X$ $Y$ $Z$

Output

If the train stops at station $Z$ during the travel from station $X$ to station $Y$, print Yes; otherwise, print No.


Sample Input 1

7 6 1 3

Sample Output 1

Yes

To travel from station $6$ to station $1$, Takahashi will take an outbound train.

After departing from station $6$, the train stops at stations $5, 4, 3, 2, 1$ in order, which include station $3$, so you should print Yes.


Sample Input 2

10 3 2 9

Sample Output 2

No

Sample Input 3

100 23 67 45

Sample Output 3

Yes

Input

Output

分数:100 分

问题描述

AtCoder 的铁路线有 $N$ 个车站,编号为 $1, 2, \ldots, N$。

在这条线上,有 进站列车 从车站 $1$ 出发,依次停靠在车站 $2, 3, \ldots, N$,还有 出站列车 从车站 $N$ 出发,依次停靠在车站 $N - 1, N - 2, \ldots, 1$。

Takahashi 准备从车站 $X$ 乘坐其中一列进站或出站列车到车站 $Y$。

请判断在这次旅行中,列车是否会停靠在车站 $Z$。

限制条件

  • $3 \leq N \leq 100$
  • $1 \leq X, Y, Z \leq N$
  • $X$,$Y$ 和 $Z$ 互不相同。
  • 所有输入值都是整数。

输入

输入从标准输入以以下格式给出:

$N$ $X$ $Y$ $Z$

输出

如果在从车站 $X$ 到车站 $Y$ 的旅行中,列车会停靠在车站 $Z$,请打印 Yes;否则,打印 No


样例输入 1

7 6 1 3

样例输出 1

Yes

为了从车站 $6$ 到达车站 $1$,Takahashi 将乘坐出站列车。

从车站 $6$ 出发后,列车会依次停靠在车站 $5, 4, 3, 2, 1$,其中包含车站 $3$,所以应该打印 Yes


样例输入 2

10 3 2 9

样例输出 2

No

样例输入 3

100 23 67 45

样例输出 3

Yes

加入题单

上一题 下一题 算法标签: