Masha and Stones

AK_74u DCC ICPC'23 Practice–1
Limits 1s, 512 MB

Masha has a good habit of collecting stones. Thus she lives by the side of the sea. Every morning she goes to walk by the side of the sea to collect different kind of beautiful stones. And she contains these stones in a jar. At one random day Masha was sitting under a tree with her random thoughts, looking at the beautiful sea. Now she is thinking, "Does each jar has the same parity or not?". By the way It's just a random thought, so don't judge Masha :p.

Same parity of each jar means,
Each jar have even number of stones or 
Each jar has an odd number of stones.”

Given the number of stones in N\bf{N} jars, you have to help Masha by Telling her if each jar has the same parity or not.


The first line of input contains a single integer N\bf{N}the number of jars Masha has.

The second line contains N\bf{N} integers J1,J2,J3,....,JN\bf{J_1, J_2, J_3,...., J_N}.(Ji\bf{J_i} means the ith\bf{i^{th}} jar contains Ji\bf{J_i} stones)

1N,Ji103\bf{1 \le N, J_i \le 10^3}


Print “Yes”, if each jar has same parity of stones. Otherwise, “No”. (without the quotation marks)


12 32 4 2 23 1 43

All numbers are not even and also all numbers are not odd. So they don’t have the same parity.

2 4 6 8 10

All numbers are even. So all of them have the same parity.

1 3 5 7 9 11

All numbers are odd. So all of them have the same parity.


Login to submit.


98% Solution Ratio
Rakib.4411Earliest, 10M ago
Jannatun.180114Fastest, 0.0s
SMshaqibLightest, 4.9 MB
user.1267Shortest, 226B
Toph uses cookies. By continuing you agree to our Cookie Policy.