103472: [Atcoder]ABC347 C - Ideal Holidays

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

Description

Score: $350$ points

Problem Statement

In the Kingdom of AtCoder, a week consists of $A+B$ days, with the first through $A$-th days being holidays and the $(A+1)$-th through $(A+B)$-th being weekdays.

Takahashi has $N$ plans, and the $i$-th plan is scheduled $D_i$ days later.

He has forgotten what day of the week it is today. Determine if it is possible for all of his $N$ plans to be scheduled on holidays.

Constraints

  • $1\leq N\leq 2\times 10^5$
  • $1\leq A,B\leq 10^9$
  • $1\leq D_1<D_2<\ldots<D_N\leq 10^9$

Input

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

$N$ $A$ $B$
$D_1$ $D_2$ $\ldots$ $D_N$

Output

Print Yes in a single line if it is possible for all of Takahashi's $N$ plans to be scheduled on holidays, and No otherwise.


Sample Input 1

3 2 5
1 2 9

Sample Output 1

Yes

In this input, a week consists of seven days, with the first through second days being holidays and the third through seventh days being weekdays.

Let us assume today is the seventh day of the week. In this case, one day later would be the first day of the week, two days later would be the second day of the week, and nine days later would also be the second day of the week, making all plans scheduled on holidays. Therefore, it is possible for all of Takahashi's $N$ plans to be scheduled on holidays.


Sample Input 2

2 5 10
10 15

Sample Output 2

No

Sample Input 3

4 347 347
347 700 705 710

Sample Output 3

Yes

Input

Output

得分:350分

问题描述

在AtCoder王国,一周由$A+B$天组成,其中前$A$天是假日,第$(A+1)$天到第$(A+B)$天是工作日。

高桥君有$N$个计划,第$i$个计划在$D_i$天后安排。

他忘记了今天是星期几。确定他的所有$N$个计划是否都可能安排在假日。

限制条件

  • $1\leq N\leq 2\times 10^5$
  • $1\leq A,B\leq 10^9$
  • $1\leq D_1<D_2<\ldots<D_N\leq 10^9$

输入

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

$N$ $A$ $B$
$D_1$ $D_2$ $\ldots$ $D_N$

输出

如果高桥君的所有$N$个计划都可能安排在假日,则在一行中打印Yes,否则打印No


样例输入1

3 2 5
1 2 9

样例输出1

Yes

在这个输入中,一周由七天组成,其中前两天是假日,第三天到第七天是工作日。

假设今天是一周的第七天。在这种情况下,过一天后将是星期一,过两天后将是星期二,过九天后也将是星期二,使得所有计划都安排在假日。因此,高桥君的所有$N$个计划都可能安排在假日。


样例输入2

2 5 10
10 15

样例输出2

No

样例输入3

4 347 347
347 700 705 710

样例输出3

Yes

加入题单

上一题 下一题 算法标签: