HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Economics & Finance > problem:


50405 - Accounts Receivable

Guest
• Review clarifications (1)

Section problems

• 51039 - Automated billing system
• 50958 - ATM
• 50482 - Bank Charges
• 50491 - Brokers
• 50806 - TVSH
• 50514 - Bookkeeping
• 50523 - Total Tax to Pay
• 50534 - Top Trading Company
• 50405 - Accounts Receivable

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Mustafa Uc, prepared by Ibrahim Mesecan.

Accounts Receivable

Accounting department of your company, records the company’s credit sales to the customers in the following account: "Accounts Receivable"

Company ID:4043
170 130
200 120
. .
D.Total C.Total
370 250
Debit Balance
120
Company ID:4185
290 80
110
. .
D.Total C.Total
290 190
Debit Balance
100
Company ID: 5174
120 100
190 30
. .
D.Total C.Total
310 130
Debit Balance
180
Accounts Receivable
170 130
200 120
290 80
120 110
190 100
30
D.Total C.Total
970 570
Debit Balance
400
And every credit sale transaction is kept in two accounts: customer’s account (account receivable) and the control account (Main Accounts Receivable).

In each subsidiary account, your credit sales appear on the left part of the subsidiary account and thus, it’s the debit of the company. And payments by the company appear on the right side.

In this process, company uses a special numbering system for every process. e.g. 120 is used for credit sales and 320 is used for purchases in credit. The numbering system includes also some other information. For example, if the country is divided into several regions after process number, they use the code for the region and then the code of the each customer. e.g. 120.5875 means this is a credit sale to the customer 875 from the 5th region. 320.4125 is a credit purchase from supplier 125 from the 4th region.

Question: Write a program which reads k transactions and then finds two information:

  • The region with the highest amount of debit balance and
  • the ID of the company with the highest amount of debit balance

Input specification
You will be given one integer at the beginning, the number of transactions (k): an integer between 0 and 2000. Then, the following k lines will have 3 information:

  • Date of transaction: three integers (Year.Month.Day) separated by periods and ending with a semicolon
  • Transaction which includes period separated 2 information
    • the process ID: an integer between 1 and 1000. But the code for credit sales is 120. Thus, other codes represent other data and will not be processed in credit sales report.
    • the company ID: an integer between 1001 and 9999. The first digit of company ID defines the region the rest is the company ID in that region.
  • Amount: a floating point number between -50000 and 50000, where negative values represent your credit sales and positive values represent the payments by the respective company

Output specification
Show two information:

  1. The region code with the highest amount of debit balance and
  2. the ID of the company with the highest amount of debit balance
Note: If there are several companies with the same highest amount of debit, show the company with the smallest ID. Please also note that company ID includes the region number.

Sample Input I
12
2015.1.15; 120.5174 -190
2015.1.15; 320.5174 1800
2015.1.15; 120.4043 -200
2015.1.15; 120.5174 100
2015.1.16; 120.5174 -120
2015.1.16; 120.4043 120
2015.1.16; 120.4043 -170
2015.1.17; 120.4185 -290
2015.1.18; 120.4043 130
2015.1.18; 120.4185 80
2015.1.18; 120.5174 30
2015.1.19; 120.4185 110
Sample Output I
4 5174

Explanation: There are three companies in the report. And the second transaction starts with the code 320. Thus, it’s not a credit sale and it’s not reported here. Then, debit balance for:

  • 4043 is $120
  • 4185 is $100 and
  • 5174 is $180
So, th region 4 has the highest total debit balance: $220. And the company with the highest debit balance is 5174 with $180.

Äëÿ îòïðàâêè ðåøåíèé íåîáõîäèìî âûïîëíèòü âõîä.

www.contester.ru