|
| 1 | +<html><body bgcolor="#000000" text="#ffffff"><table><tr><td colspan="2"><h3>Problem Statement</h3></td></tr><tr><td>    </td><td>In Olympic boxing, there are five judges who press a button when they think |
| 2 | +that a particular boxer has just landed a punch. The times of the button |
| 3 | +presses are recorded, and the boxer receives credit for a punch if at least |
| 4 | +three of the judges press their buttons within 1 second of each other. |
| 5 | +<p> |
| 6 | +This "algorithm" needs a lot of refinement. Here is the version that you |
| 7 | +should implement. |
| 8 | +Find the maximum number of disjoint time intervals that can be chosen such that |
| 9 | +each interval is of duration 1 second or less and contains button presses from |
| 10 | +at least 3 different judges. Two intervals are disjoint if every time within one interval is |
| 11 | +strictly less than every time in the other. We give the boxer credit for one punch during |
| 12 | +each interval. |
| 13 | +</p><p> |
| 14 | +The duration of an interval is the amount of time between the instant when it starts and when it |
| 15 | +ends, and a punch may be included in an interval if its recorded time is |
| 16 | +at the start, end, or in between. |
| 17 | +So, for example, the interval from 1 to 4 has duration 3, and a punch recorded at time 1, 2, 3, or 4 |
| 18 | +is in that interval. The intervals 1 to 4 and 5 to 22 are disjoint, but the intervals 1 to 4 and 4 to |
| 19 | +22 are not disjoint. |
| 20 | +</p><p> |
| 21 | +Create a class Boxing that contains a method maxCredit that is given five vector <int>s, |
| 22 | +<b>a</b>, <b>b</b>, <b>c</b>, <b>d</b>, and <b>e</b>, representing the times of the button presses of the five judges |
| 23 | +in milliseconds. The method returns the maximum credits that can be given to the |
| 24 | +boxer. |
| 25 | +</p> |
| 26 | +</td></tr><tr><td colspan="2"><h3>Definition</h3></td></tr><tr><td>    </td><td><table><tr><td>Class:</td><td>Boxing</td></tr><tr><td>Method:</td><td>maxCredit</td></tr><tr><td>Parameters:</td><td>vector <int>, vector <int>, vector <int>, vector <int>, vector <int></td></tr><tr><td>Returns:</td><td>int</td></tr><tr><td>Method signature:</td><td>int maxCredit(vector <int> a, vector <int> b, vector <int> c, vector <int> d, vector <int> e)</td></tr><tr><td colspan="2">(be sure your method is public)</td></tr></table></td></tr><tr><td colspan="2"><h3>Limits</h3></td></tr><tr><td>    </td><td><table><tr><td>Time limit (s):</td><td>2.000</td></tr><tr><td>Memory limit (MB):</td><td>64</td></tr></table></td></tr><tr><td colspan="2"><h3>Constraints</h3></td></tr><tr><td align="center" valign="top">-</td><td>Each of the five arguments will contain between 0 and 50 elements inclusive.</td></tr><tr><td align="center" valign="top">-</td><td>Each element of each of the arguments will be between 0 and 180,000 inclusive.</td></tr><tr><td align="center" valign="top">-</td><td>The elements within each of the arguments will be in strictly increasing order.</td></tr><tr><td colspan="2"><h3>Examples</h3></td></tr><tr><td align="center" nowrap="true">0)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{1,2,3,4,5,6}</pre></td></tr><tr><td><pre>{1,2,3,4,5,6,7}</pre></td></tr><tr><td><pre>{1,2,3,4,5,6}</pre></td></tr><tr><td><pre>{0,1,2}</pre></td></tr><tr><td><pre>{1,2,3,4,5,6,7,8}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 6</pre></td></tr><tr><td><table><tr><td colspan="2"> |
| 27 | + |
| 28 | + This match had a fast start, with 6 punches credited in the first 6 |
| 29 | + milliseconds of the match! One way to choose 6 disjoint intervals is |
| 30 | + to choose [1,1], [2,2], [3,3], [4,4], [5,5], [6,6] each of which |
| 31 | + contains button presses from judges a, b, and c. |
| 32 | + There are three button presses in the time interval from |
| 33 | + 7 through 8, but |
| 34 | + only from two different judges so no additional credit can be given. |
| 35 | + |
| 36 | +</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">1)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{100,200,300,1200,6000}</pre></td></tr><tr><td><pre>{}</pre></td></tr><tr><td><pre>{900,902,1200,4000,5000,6001}</pre></td></tr><tr><td><pre>{0,2000,6002}</pre></td></tr><tr><td><pre>{1,2,3,4,5,6,7,8}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 3</pre></td></tr><tr><td><table><tr><td colspan="2"> |
| 37 | + |
| 38 | + One way to form three intervals is [0,1000], [1001,2000], [6000,6002] |
| 39 | +</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">2)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>{5000,6500}</pre></td></tr><tr><td><pre>{6000}</pre></td></tr><tr><td><pre>{6500}</pre></td></tr><tr><td><pre>{6000}</pre></td></tr><tr><td><pre>{0,5800,6000}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 1</pre></td></tr><tr><td><table><tr><td colspan="2"> |
| 40 | + Any interval that doesn't include 6000 will not have enough button presses, |
| 41 | + so we can form only one disjoint interval with credit for a punch. |
| 42 | +</td></tr></table></td></tr></table></td></tr></table><p>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. </p></body></html> |
0 commit comments