The Game Of StacksProblem code: CB07 |
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.
Input
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.
Output
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.
Example
Input: 2 5 3 1 2 3 4 5 5 3 5 6 3 1 6 Output: Play Not Play
| Author: | moneymachine |
| Date Added: | 17-01-2010 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions

Any hints for the algorithm ?
Any hints for the algorithm ?