Editorial for An Animal Contest 5 P1 - Bamboo Cookies


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: sjay05

Subtask 1 + 2

Any two pairs (i,j) can be paired to sum to an even number as all ai equal 1 or 2. The operation can be performed n2 times.

Time Complexity: O(1)

Subtask 3

  • If N=1, the answer is 0.
  • If N=2, the answer can be 0 or 1.
  • If N=3, the answer is 1.

Time Complexity: O(1)

Subtask 4

An even number can only be created by summing two even or two odd numbers. The answer is odd2+even2 where odd and even are the number of odd and even values in a.

Time Complexity: O(N)


Comments

There are no comments at the moment.