Time limit: 1 second Memory limit: 256 MB In the dormitory, people will take turns to…
- User
Time limit: 1 second Memory limit: 256 MB In the dormitory, people will take turns to buy dinner or stuff for dinner. Each night one person goes out to buy and writes details of it on the "Detail Paper". Details include the name of the buyer, the amount of money he/she paid and the name of the people who ate that night. Image below shows a Detail Paper.
At the end of each month everyone has to pay their debts, but everyone gets so creepy when it comes to money. So they all decided to hire a team from ACM (Abdominal Control Market) of the SBU University.
Description of the image
you are one of the teams participating in ACM Newbies Contest so you have to help them. They only have two rules:
Only people that ate, should pay (name of them is written in Detail Paper) The money paid by everyone on each night must be equal. input First line of input contains an integer T T indicating the number of test cases. Each test case contains an integer L L, number of lines to follow. L ≤ 50 L≤50
Each line of test case is as follows: A string S S name of the buyer followed by an integer c C cost of things bought followed by an integer N N, indicating how many people ate that specific night, Following N space separated strings indicating the name of the people that ate that night. It's guaranteed that C is divisible by N and each line contains no more than 250 characters.
0 < c < 100 , 000 0<C<100,000 N ≤ 10 N≤10
Each Name contains "A-Z" and "a-z" characters. Names are NOT case-sensitive and the length of each name is at most 20 characters.
output For each test case output "Case #X:" (quotations for clarification) which X is the number of test case.
Then print "Debtors:" (quotations for clarification) and in each line print name of debtors and their liability as follows sorted by debtors name in alphabetical order: "S owes D Tomans." (quotations for clarification)
First alphabetic character of S must be uppercase and rest of alphabetic characters must be lowercase, D is an integer number (money person S must pay).
Then print "Creditors:" (quotations for clarification) and in each line print name of creditors and their credit as follows sorted by creditors name in alphabetical order: "S paid D Tomans." (quotations for clarification)
First alphabetic character of S must be uppercase and rest of alphabetic characters must be lowercase, D is an integer number (money person S must get).
People who don't have to pay or receive any money are neither Debtor nor Creditor, so their name should not appear in output.
examples Sample entry 1 2 10 Michel 9200 4 Aden John David Michel Ashley 8700 3 Ashley Aden John Ashley 6000 3 Michael John Ashley Aden 15000 3 Ashley John Aden Michel 1800 4 Aden David Michel Ashley David 2200 4 Aden John David Ashley Aden 29400 3 Aden David Ashley Aden 8500 4 Aden David Ashley John John 21000 3 Aden Michel John Aden 3100 2 Aden Michel 1 Ehsan 4500 1 Ehsan Plain text Sample output 1 Case #1: Debtors: Ashley owes 8125 Tomans. David owes 13025 Tomans. John owes 875 Tomans. Michel owes 2300 Tomans. Creditors: Aden paid 24325 Tomans. Case #2: Debtors: Creditors: write code in java17
- Assistant