JOIN

   Problem Statement  

 Problem Statement for EllysCandies

Problem Statement

    

There are several boxes containing candy in front of Elly and Kris. The girls play the following game. Starting with Elly, they take alternating turns. In each turn the girl whose turn it is takes one of the boxes and eats all the candies it contains. Then the same number of candies as there were in the box that was just taken is added to each of the remaining boxes.

For example, let's imagine there are five boxes containing {40, 13, 17, 1, 11} candies. If in the first turn Elly decides to take the second box, she will eat 13 candies and then the remaining boxes will contain {40+13, 17+13, 1+13, 11+13} = {53, 30, 14, 24} candies. If then on the second turn Kriss takes the last box, she will eat 24 candies and after her turn the three remaining boxes will contain {77, 54, 38} candies.

The game is played until there are no more boxes. The girl who has eaten more candies in total is declared the winner (and quite likely - a diabetic).

You are given the initial number of candies in each of the boxes in the int[] boxes. Assuming both girls play optimally, return "Elly", if Elly will win, "Kris", if Kris will win, or "Draw" if they will end up with the same score.

 

Definition

    
Class:EllysCandies
Method:getWinner
Parameters:int[]
Returns:String
Method signature:String getWinner(int[] boxes)
(be sure your method is public)
    
 

Notes

-The return value is case-sensitive. The quotes around the strings you should return are only for clarity.
 

Constraints

-boxes will contain between 2 and 20 elements, inclusive.
-Each element of boxes will be between 1 and 1000, inclusive.
 

Examples

0)
    
{4, 2}
Returns: "Kris"
No matter whether Elly takes the 4 or the 2, in the next turn Kris will take 6 and win.
1)
    
{1, 1, 1000}
Returns: "Elly"
Here one way for Elly to win is to take one of the ones, leaving {2, 1001} for Kris to choose from. If Kris takes the 2, Elly will obviously win. If Kris takes the 1001, Elly will take 1003 in the last turn and win.
2)
    
{42, 42, 42, 42, 42, 42, 42, 42}
Returns: "Kris"
There isn't much choice in this test case - at every turn all numbers are the same. In the end Kris ends up having eaten more candy.
3)
    
{42, 13, 17, 666, 55, 100, 3, 20, 81, 42, 123}
Returns: "Elly"

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2025, TopCoder, Inc. All rights reserved.

This problem was used for:
       2020 TCO Algo Round 1B - Division I, Level One
       2020 TCO Algo Parallel 1B - Division I, Level One