Problem A
Alice and colourful eggs
Easter bunny Alice arranged $n$ colourful Easter eggs in a row, producing a beautiful pattern. The $i$-th egg has an integer serial number $a_i$ which specifies its colour as $a_i$ modulo $k$. $k$ is an integer, representing the number of possible colours.
Alice does not want to change the colour pattern, but wonders if it is possible to sort the serial numbers into a non-decreasing order by only swapping eggs of the same colour (or none at all).
Input
The first line of the input contains two numbers $n$ ($1 \le n \le 1000$) and $k$ ($1 \le k \le 10^9$) — the number of eggs and the number of possible colours.
The second line of the input file contains $n$ integers $a_i$ — the initial arrangement ($1 \le a_i \le 10^9$).
Output
Output “YES” if Alice can sort the serial numbers and “NO”, otherwise.
Notes
In the first testcase, Alice can swap eggs $1$ and $5$ (both of colour $1$), and eggs $2$ and $4$ (both of colour $0$).
Sample Input 1 | Sample Output 1 |
---|---|
5 2 5 4 3 2 1 |
YES |
Sample Input 2 | Sample Output 2 |
---|---|
3 2 2 3 1 |
NO |