Submit | All submissions | Best solutions | Back to list |
Problem hidden
MSE06D - Sherlock Holmes |
English | Vietnamese |
Sherlock Holmes, the well known detective, must solve a puzzling situation. He has n boxes B1, B2, .., Bn , where n is even, each containing m balls. The balls are white and black. Let Bi = (Wi, Bi) denote a box with Wi white balls and Bi black balls. He must partition the boxes into two sets, each consisting of n/2 boxes, such that either the white balls or the black balls hold a majority in both sets. If there is such a majority, let m1 and m2 denote the percentage of the majority balls in each set. Holmes must find very quickly the maximum possible value of min(m1, m2). Can you help Holmes?
The program input is from a text file. Each data set in the file stands for a particular set of boxes. A data set starts with the number n (n < 10000) of boxes. Follows the number m (m < 10000) of balls, and for each box the number (< 10000) of white and black balls in this specific order.
The program prints the color (W or B) of the balls that hold the majority followed by the maximum value - if there is such a majority, or "No solution" if no majority can be obtained.
White spaces can occur freely in the input. The input data are correct and terminate with an end of file. For each set of data the program prints the result to the standard output from the beginning of a line.
An input/output sample is in the table below. There is a single data set that contains 4 boxes each containing 30 balls. The first box, for example, contains 17 white balls and 13 black balls. There is only one possible partition of the boxes (B1, B4), (B2, B3), the white balls holding majority. The result for the data set is the identifier W and the maximum value.
Sample
Input : 4 30 17 13 12 18 20 10 14 16 Ouput: W 51.67
Added by: | psetter |
Date: | 2009-04-16 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |
Resource: | Southeastern European 2006 |
hide comments
2009-04-27 13:14:12 [Trichromatic] XilinX
So this problem will be hidden until the test case has been corrected. |
|
2009-04-27 10:30:10 Ivan Katanic
There is an extra line "No solution\n" at the end of the output file. Last edit: 2009-04-27 10:43:16 |
|
2009-04-19 19:54:11 .:: Pratik ::.
"Holmes must find very quickly the maximum possible value of min(m1, m2)." Shouldnt the answer be a integer then? Or is something wrongly stated? Thanks |