[Solution] Colored Balls: Revisited Codeforces Solution
The title is a reference to the very first Educational Round from our writers team, Educational Round 18.
There is a bag, containing colored balls. There are different colors of balls, numbered from to . There are balls of color in the bag. The total amount of balls in the bag is odd (e. g. is odd).
In one move, you can choose two balls with different colors and take them out of the bag.
At some point, all the remaining balls in the bag will have the same color. That's when you can't make moves anymore.
Find any possible color of the remaining balls.
The first line contains a single integer () — the number of testcases.
The first line of each testcase contains a single integer () — the number of colors.
The second line contains integers () — the amount of balls of each color in the bag.
The total amount of balls in the bag is odd (e. g. is odd).
For each testcase, print a single integer — any possible color of the remaining balls, after you made some moves and can't make moves anymore.
Note
In the first testcase, your first and only move can be one of the following:
- take balls with colors and ;
- take balls with colors and ;
- take balls with colors and .
After the move, exactly one ball will remain. Its color can be or depending on the move.
In the second testcase, you can't make moves at all — there is only color of balls already. This color is .
In the third testcase, you can keep removing one ball of color and one ball of color until there are no more balls of color . At the end, three balls of color remain.
No comments:
Post a Comment