#C809. Alice's Winning Strategy

    ID: 52033 Type: Default 1000ms 256MiB

Alice's Winning Strategy

Alice's Winning Strategy

In this problem, you are given an array of integers of size (n) and you need to determine whether Alice can guarantee a win in a two-player game by playing optimally. The game is defined as follows:

  • If the total sum \(S = \sum_{i=1}^{n} a_i\) is odd, then Alice can guarantee a win immediately.
  • If \(S\) is even, both players will choose numbers in a greedy manner from the sorted (in descending order) list of integers: Alice picks first, then Bob, and so on. If the sum of numbers picked by Alice is strictly greater than the sum of numbers picked by Bob, then Alice wins; otherwise, Bob wins.

Your task is to implement a program that takes the size of the array and its elements as input from standard input and prints either "ALICE" or "BOB" to standard output, depending on whether Alice can guarantee a win or not.

inputFormat

The first line contains a single integer (n) ((1 \le n \le 10^5)), the number of elements in the array. The second line contains (n) space-separated integers (a_1, a_2, \ldots, a_n) where each (a_i) fits in a 32-bit signed integer.

outputFormat

Output a single line containing either "ALICE" if Alice can guarantee a win, or "BOB" otherwise.## sample

5
3 9 1 2 7
ALICE