ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > CEN111 Homeworks 2013-2015 > задача:


14-Fall2-50. 50534 - Top Trading Company

CEN111 Homeworks 2013-2015

Старт: 10.янв.2015 в 10:00:00
Финиш: 10.янв.2015 в 15:00:00
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (3)

Задачи турнира

• 14-Fall1-10. 50532 - Close City
• 14-Fall1-30. 50500 - Find Student
• 14-Fall1-40. 50511 - Class Average
• 14-Fall1-50. 50481 - Car Parking
• 14-Fall2-10. 50510 - What floor are ...
• 14-Fall2-20. 50504 - School contest
• 14-Fall2-30. 50523 - Total Tax to Pay
• 14-Fall2-40. 50514 - Bookkeeping
• 14-Fall2-50. 50534 - Top Tradin...
• 14-Fall2-60. 50487 - Radius of Inscr...
• 14-FallResit-20. 50407 - Missing Nu...
• 14-Spr2-10. 50426 - Calculating Sales
• 14-Spr2-20. 50425 - Calculating W...
• 14-Spr2-30. 50445 - Cryptography
• 14-Spr2-50. 50437 - Age Labeling
• 15-FallHW-2. 50821 - Derivative of ...
• 15-FallHW-3. 50822 - Linked List

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 3500/6000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Top Trading Company

Your company grows now. And you are trading with many companies. So, you are recording transactions of n companies in a file. Every company transactions are listed in a line with a positive or negative number:

  • debits are negative (you paid for your buys) and
  • credits are positive (you are paid for what you sell).
Because every company have different number of transactions, the transactions end with a 0 (zero). Then, your balance is
Balance = (Your income)- (your expenses)

Question: Write a program that is going to calculate the total balance and the company with which you have the most trade (buys + sells).

Input specification
You will be given an integer (n) the number of companies where 0 ≤ n ≤ 2000. Then, in each of the following n lines you will be given:

  • Company ID: a string starting with two letters (from 26 uppercase English chars) and consisting of 4 digits
  • at most 250 floating point (positive or negative) numbers ending with a 0 (zero).

Output specification:
Show two information:

  1. Total balance: floating point number with 2 digits precision
  2. The ID of company with which you have the most trade (buys + sells)
Note: If there are several companies with the same most trade amount, show the company which appears the first.

Sample Input I
4
NL5755 60 70 -25.5 0
AM1966 -25 -60 0
SB9468 82 -20 34 -53 0
TB1567 60.5 -44 66 0
Sample Output I:
145 SB9468

Explanation: Here are the company balances according to given information:

  Buys Sells Balance Total Trade
NL5755 -25.5 130 104.5 155.5
AM1966 -85 0 -85 85
SB9468 -73 116 43 189
TB1567 -44 126.5 82.5 170.5
Then, total balance is 145 (104.5 - 85 + 43 + 82.5), and the company with which you have the most trade is SB9468, because total buys and sells is the max (189).



Для отправки решений необходимо выполнить вход.

www.contester.ru