The Game Of Stacks
All submissions for this problem are available.
The game of stacks is played among K players as follows: Initially there are N stacks of coins where the i'th stack has X(i) coins. In his turn, each player can choose any stack and remove any number of coins ( greater than 0 ) from it. The player who is not able to pick any coin during his turn will be considered the worst ranked player. The players following him will be ranked 2nd worst, 3rd worst, and so on.
You have been asked to play first. You have decided to play the game if and only if your rank is not bound to be the worst assuming that each player plays optimally. You need to output "Play" if your rank is not bound to be the worst, and "Not Play" otherwise.
The first line contains the number of test cases T, at most 20, followed by T test cases. Each test case begins on a new line containing the values of N and K, where 1 <= N <= 100,000 and 1 <= K <= 100,000. The next line contains N space separated integers X(1), X(2),..., X(N) where for each i, 1 <= X(i) <= 100,000,000.
For each test case in the input, you need to output "Play" if you rank is not bound to be the worst, and "Not Play" otherwise. Print the result of each test case on a new line.
Input: 2 5 3 1 2 3 4 5 5 3 5 6 3 1 6 Output: Play Not Play
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.