UF2015J - Automated Dispatch
In order to automate shipping, your manager at Gainesville Computer Company (GCC) has assigned you the task of sending a dispatch message to the driver once a truck is completely loaded with the required type goods.
The truck leaves the GCC warehouse whenever K laptops have been loaded into it. A scanner is placed in the assembly line to automatically identify items being loaded into the truck. GCC ships out many different products, each of which is identified by an ID. After each item is loaded, its ID (not necessarily unique) is recorded. Given N IDs can you determine whether we should tell the driver to depart or not?
Input
The input will begin with a line containing a single positive integer, t, representing the number of test cases to process. Each test case will begin with two integers N and K (1 ≤ K ≤ N ≤ 1,000,000), which are the same as described above. The next line will contain N space delimited integers, each corresponding to the ID of a product loaded on the truck. If an ID is not positive it corresponds to a laptop; otherwise it is not a laptop.
Output
For each test case print "DISPATCH" if the required number of items is loaded, otherwise print "WAIT". The output for each test case should be on its own line.
Example
Input: 2
4 3
-1 -3 4 2
4 2
0 -1 2 1 Output: WAIT
DISPATCH
Added by: | Cormac |
Date: | 2015-02-19 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 JS-MONKEY |
Resource: | UF High School Programming Contest 2015 |