لینک‌های مفید برای شرکت در مسابقه:

در طول مسابقه، می‌توانید سؤالات خود را از قسمت «سؤال بپرسید» مطرح کنید.

E – Dormitory Nights


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

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 name of the buyer, amount of money he/she paid and name of the people ate that night.

توضیح تصویر

At the end of each month everybody have to pay their debts, But everyone get’s so creepy when it comes to money. So they all decided to hire a team from ACM(Abdominal Control Market) of the SBU University. you are one of the teams participating in ACM Newbies Contest so you have to help them. They only have two rules:

  1. Only people that ate, should pay (name of them is written in Detail Paper)
  2. The money paid by everyone on each night must be equal.

ورودی🔗

There are some test cases in one test(at most 200), Each test case contains an integer L(L50)L (L ≤ 50), number of lines to follow. Each line of test case is as following: A string SS name of the buyer followed by an integer C(0<C<100000)C(0<C<100000) cost of things bought followed by an integer N(N10)N(N≤10), indicating how many people ate that specific night, Following NN space separated strings indicating namename of the people that ate that night. It’s guaranteed that CC is divisible by NN and Each line contains no more than 250250 characters. Each NameName contains “A-Z” and “a-z” characters. NamesNames are NOT case-sensitive and length of each name is at most 20 characters. (Case-Sensitive: ‘a’ ≠ ‘A’, not case-sensitive: ‘a’ = ‘A’)

خروجی🔗

For each test case output “Case #X:” (quotations for clarify) which XX is the number of test case. Then print “Debtors:” (quotations for clarify) and in each line print name of debtors and their liability as following sorted by debtors name in alphabetical order:

S owes D Tomans.

First alphabetical character of SS must be uppercase and rest of alphabetical characters must be lowercase, DD is an integer number (money person SS must pay). Then print “Creditors:” (quotations for clarify) and in each line print name of creditors and their credit as following sorted by creditors name in alphabetical order:

S paid D Tomans.

First alphabetical character of SS must be uppercase and rest of alphabetical characters must be lowercase, DD is an integer number (money person SS 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.

مثال‌ها🔗

ورودی نمونه ۱🔗

10
Michel 9200 4 Aden John David Michel
Ashley 8700 3 Ashley Aden John
Ashley 6000 3 Michel 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

خروجی نمونه ۱🔗

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:
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.