One-Sized Game

4.5

8 votes
Easy, Quick Sort, Simulation, Sorting, approved
Problem

Ladia and Kushagra are playing the One-Sized Game. The rules of this game are pretty simple.

They have an array consisting of N elements (1-indexed). In each step, one needs to find out the smallest element present in the array. Get the index of that element and subtract that value (index value) from every element of the array. If there is a clash/collision between the smallest element, pick the one that occurs first -- that is the one having smaller index. This process is repeated several times. Whenever an element's value goes below 0 this element gets removed from the array and the array gets re-sized.

During the game's play, if at any point of time, the array is left with only one element, Ladia wins the game otherwise Kushagra wins.

Given an array consisting of N elements, print whether Ladia will win or Kushagra.

Input:

The first line contains an integer T denoting the number of test-cases. Each test case begins with an integer N that denotes the size of the array. This is followed up by N space separated integers.

Output:

For each test case print whether "Ladia" wins or "Kushagra" (without quotes).

Constraints:

1 <= T <= 5

1 <= N <= 105

0 <= Array Value <= 109

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation
  • Game 1 :

The smallest element is 2 ,since there is a collision we pick index 2 over 3 as it is smaller. We then subtract 2 from the entire array.

New array- {3,0,0}

Smallest element is 0, again we pick index 2 and subtract 2 from entire array.

New array - {1,-2,-2}

Since we have elements <0 ,they get deleted. Modified array - {3}. The size of array is now 1. So Ladia wins this game.

  • Game 2:

Smallest element is 3,index is 1. So we subtract 1 from the entire array. Repeat this process 4 times. We get array

New array - {3,2}

Smallest element is 2,index is 2. So we subtract 2 from the entire array.

New array - {1,0}

Smallest element is 0, index is 2. Subtract 2 from the array.

New array - {-1,-2}. Negative element gets deleted. Modified array - { }. So Kushagra wins this game.

Editor Image

?