atcoder#ARC161A. [ARC161A] Make M
[ARC161A] Make M
Score : points
Problem Statement
Let be a positive odd number. A sequence of integers of length , , is said to be M-type if "for each even number , it holds that and ".
You are given a sequence of positive integers of length , . Determine if it is possible to rearrange to be M-type.
Constraints
- is an odd number.
Input
The input is given from Standard Input in the following format:
Output
If it is possible to rearrange the given integer sequence to be M-type, print Yes
; otherwise, print No
.
5
1 2 3 4 5
Yes
The given sequence is . After rearranging it, for example, to ,
- for , it holds that and ;
- for , it holds that and .
Therefore, this sequence is M-type, and the answer is Yes
.
5
1 6 1 6 1
Yes
The given sequence itself is M-type.
5
1 6 6 6 1
No
It is impossible to rearrange it to be M-type.