Codeforces Round 562 (Div. 2)
A
Circle Metro
Codeforces
900
原题
←B →
翻译中…

The circle line of the Roflanpolis subway has $n$ stations.

翻译中…

There are two parallel routes in the subway. The first one visits stations in order $1 \to 2 \to \ldots \to n \to 1 \to 2 \to \ldots$ (so the next stop after station $x$ is equal to $(x+1)$ if $x \lt n$ and $1$ otherwise). The second route visits stations in order $n \to (n-1) \to \ldots \to 1 \to n \to (n-1) \to \ldots$ (so the next stop after station $x$ is equal to $(x-1)$ if $x \gt 1$ and $n$ otherwise). All trains depart their stations simultaneously, and it takes exactly $1$ minute to arrive at the next station.

翻译中…

Two toads live in this city, their names are Daniel and Vlad.

翻译中…

Daniel is currently in a train of the first route at station $a$ and will exit the subway when his train reaches station $x$.

翻译中…

Coincidentally, Vlad is currently in a train of the second route at station $b$ and he will exit the subway when his train reaches station $y$.

翻译中…

Surprisingly, all numbers $a,x,b,y$ are distinct.

翻译中…

Toad Ilya asks you to check if Daniel and Vlad will ever be at the same station at the same time during their journey. In other words, check if there is a moment when their trains stop at the same station. Note that this includes the moments when Daniel or Vlad enter or leave the subway.

翻译中…

Input

翻译中…

The first line contains five space-separated integers $n$, $a$, $x$, $b$, $y$ ($4 \leq n \leq 100$, $1 \leq a, x, b, y \leq n$, all numbers among $a$, $x$, $b$, $y$ are distinct) — the number of stations in Roflanpolis, Daniel's start station, Daniel's finish station, Vlad's start station and Vlad's finish station, respectively.

翻译中…

Output

翻译中…

Output "YES" if there is a time moment when Vlad and Daniel are at the same station, and "NO" otherwise. You can print each letter in any case (upper or lower).

翻译中…

Note

翻译中…

In the first example, Daniel and Vlad start at the stations $(1, 3)$. One minute later they are at stations $(2, 2)$. They are at the same station at this moment. Note that Vlad leaves the subway right after that.

翻译中…

Consider the second example, let's look at the stations Vlad and Daniel are at. They are:

翻译中…
  • initially $(2, 9)$,
  • after $1$ minute $(3, 8)$,
  • after $2$ minutes $(4, 7)$,
  • after $3$ minutes $(5, 6)$,
  • after $4$ minutes $(6, 5)$,
  • after $5$ minutes $(7, 4)$,
  • after $6$ minutes $(8, 3)$,
  • after $7$ minutes $(9, 2)$,
  • after $8$ minutes $(10, 1)$,
  • after $9$ minutes $(1, 10)$.
翻译中…

After that, they both leave the subway because they are at their finish stations, so there is no moment when they both are at the same station.

翻译中…

样例

Input #1
5 1 4 3 2
Output #1
YES
InputCopy OutputCopy
Input #2
10 2 1 9 10
Output #2
NO
InputCopy OutputCopy
题目信息
题号
1169A
时间限制
1 s
内存限制
256 MB
标签
模拟
数学

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