| The 4th Turing Cup |
|---|
| Закончено |
According to Wikipedia, Mahjong or mah-jongg is a tile-based game that was developed in the 19th century in China and has spread throughout the world since the early 20th century. It's a strategic game and the goal of the game is to draw tiles to form a legal hand with 14 tiles.
In the traditional game of Mahjong, there are many different types of tiles. For each type of tiles, there could be different symbols on it representing different numbers. For example, the graph below lists the same type of tiles, and they represent 1 to 9 respectively.
To simplify the game for this problem, we invent a generalized Mahjong. In our game, there is only one type of tiles, and the numbers on them are 1, 2, 3, ... to $$$n$$$. ($$$n$$$ could be larger than 9). For example, when $$$n = 6$$$, we have the following 6 tiles of the same type of tile.
In the generalized Mahjong, there can be an unlimited number of tiles for each symbol, and the number of tiles in each player's hands is unlimited as well. $$$x$$$ and $$$y$$$ will be given as input to define "Pong" and "Chow", in order to explain what is a legal hand.
A legal hand in the generalized Mahjong means that all tiles in one player's hands are a combination of "Pong"s and "Chow"s without any extra tiles.
The picture below shows a legal hand when $$$n = 9, x = 3$$$, and $$$y = 3$$$. This is also the first sample test case below.
The picture below shows how the hand of tiles can be divided into "Pong"s and "Chow"s. It's (1, 1, 1) "Pong", (9, 9, 9) "Pong", (1, 2, 3) "Chow", (4, 5, 6) "Chow", (6, 7, 8) "Chow".
Now given $$$n, x, y$$$, the modified rules explained above, and a hand of tiles, please print 'Yes' if it's a legal hand; otherwise please print out 'No'.
The first line contains three integers, representing $$$n$$$ ($$$1 \leq n \leq 10^3$$$), $$$x$$$, and $$$y$$$ ($$$1 \leq x, y \leq 10^9$$$).
The second line contains $$$n$$$ integers $$$a_1, \dots, a_n$$$, where $$$a_i$$$ is the number of the $$$i$$$th tile.
If the hand of tiles is legal, print Yes, otherwise print No.
9 3 3 4 1 1 1 1 2 1 1 3
Yes
9 3 4 2 1 0 2 2 2 0 1 2
No
Subtask 1 (40pts): $$$n=x=y=3$$$.
Subtask 2 (30pts): $$$y=n+1$$$.
Subtask 3 (30pts): No special restrictions.
For $$$100\%$$$ of data, $$$n \leq 1000$$$, $$$1 \leq x,y \leq 10^9$$$, $$$0 \le a_i \le 10^9$$$.
| Название |
|---|


