#GD0000189. Trò chơi chẵn – lẻ (Even-Odd Game)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Trò chơi chẵn – lẻ (Even-Odd Game)
Even-Odd Game
Source: Codeforces
Version: Phuoc Hung OJ (single-case adaptation where applicable)
Problem Statement
Alice and Bob alternately remove one positive integer from an array, Alice first. Alice scores the value of an even integer she removes, otherwise zero. Bob scores the value of an odd integer he removes, otherwise zero. Both play optimally to maximize their score difference. Determine the winner or a tie.
Input
The first line contains . The second contains positive integers .
Output
Print Alice, Bob, or Tie according to optimal play.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Example 1
Input
4
5 2 7 3
Output
Bob
Explanation
Sorted values are 7, 5, 3, 2. Alice discards 7, Bob scores 5, and neither scores on the final two turns. Bob wins.
Example 2
Input
3
3 2 1
Output
Tie
Explanation
Alice first discards 3, Bob discards 2, and Alice discards 1; no one scores, so the result is a tie.