PayBill
SRM 219 · 2004-11-20 · by erinn
Problem Statement
You have just finished your delicious Chinese food dinner with your friends, and divided up the
bill. You are given the
You now need to determine, based upon the price of each person's meal, and the amount of money
that has been paid, which of your friends has paid. You are to return a
Constraints
- meals will contain between 1 and 50 elements, inclusive.
- Each element of meals will be between 1 and 10000, inclusive.
- totalMoney will be between 0 and 500000, inclusive.
- There will be exactly one unique solution to the problem.
{ 1000, 1200, 1300 }
2500
Returns: { 1, 2 }
Clearly, the only way there can be 2500 on the table is if person 1 and 2 have paid, but person 0 has not.
{ 100, 200, 350 }
300
Returns: { 0, 1 }
Of course, 100 + 200 = 300.
{ 150, 200, 350, 400 }
900
Returns: { 0, 2, 3 }
Here, we have 150 + 350 + 400 = 900.
{6584,6733,6018,5840,2723,4902,4260,
5375,6745,1234,3000,8222,2472,
4348,1716,9995,415,1234,2345,5679}
70630
Returns: { 0, 1, 3, 4, 5, 6, 8, 9, 11, 13, 14, 15, 16, 17, 19 }
{3,5,6,7}
10
Returns: { 0, 3 }
Submissions are judged against all 23 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class PayBill with a public method vector<int> whoPaid(vector<int> meals, int totalMoney) · 23 test cases · 2 s / 256 MB per case