CoinMachinesGame
TCO11 Qual 3 · 2011-05-07 · by soul-net
Problem Statement
In an arcade palace, there are several machines with games that you like to play. It costs some number of coins to play a single game on each machine. However, these machines have a peculiarity: after each game, they give back some of the coins that you inserted. You wonder how many games in total you can play with the coins you have. It is possible to play the game on the same machine many times.
You will be given an
Return the maximum possible number of games that you can play.
Constraints
- coins will be between 1 and 1000000000 (10^9), inclusive.
- need will contain between 1 and 50 elements, inclusive.
- need and give will contain the same number of elements.
- Each element of need and give will be between 1 and 1000, inclusive.
- Element i of give will be strictly less than element i of need.
10
{5,3}
{4,1}
Returns: 7
You can play 5 times on the first machine and 2 times on the second machine, in that order. There are other ways to get 7 games in total.
1000
{16,14,11,7}
{15,12,8,3}
Returns: 988
1000000000
{1000,900,800,700,600,500,400,300,200,100}
{701,802,503,604,405,306,107,208,1,1}
Returns: 10869564
12345678
{342,234,65,76,85,734,67,345,70,234}
{45,78,3,10,45,12,45,57,1,230}
Returns: 3086370
1
{2}
{1}
Returns: 0
Submissions are judged against all 131 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class CoinMachinesGame with a public method int maxGames(int coins, vector<int> need, vector<int> give) · 131 test cases · 2 s / 256 MB per case