PlayGame
SRM 217 · 2004-10-27 · by Olexiy
Problem Statement
You will be given a
Constraints
- you and computer will have the same number of elements.
- you and computer will contain between 1 and 50 elements, inclusive.
- Each element of you and computer will be between 1 and 1000, inclusive.
Statement by TopCoder, Inc. — view the original on the archive.
{5, 15, 100, 1, 5}
{5, 15, 100, 1, 5}
Returns: 120
Your units with strengths of 100 and 15, along with one of your strength 5 units, can avoid capture.
{1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000}
{1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000}
Returns: 0
All units are equally strong, so all your units are captured.
{1, 2, 3, 4, 5, 6, 7, 8, 9}
{1, 2, 3, 4, 5, 6, 7, 8, 9}
Returns: 44
{1, 3, 5, 7, 9, 11, 13, 15, 17, 19}
{2, 4, 6, 8, 10, 12, 14, 16, 18, 20}
Returns: 99
You assign your weakest unit to the computer's strongest unit. Then you assign all your other units in such a way that each of your units has a strength one higher than the opposing unit. So all your units except the weakest one avoid capture.
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
Returns: 65
All your units can win.
Submissions are judged against all 78 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class PlayGame with a public method int saveCreatures(vector<int> you, vector<int> computer) · 78 test cases · 2 s / 256 MB per case