Programming contests

ECN programozó csapatverseny, 2017. május 13.

May 13, 2017 10:10 AM – May 13, 2017 3:10 PM

Software System for the Ministry of Healthcare

The Ministry of Healthcare must implement a software system for the management of expenses.

Input Specification

The input contains:

  • on the first line, an integer n (n ≤ 200 000), the number of persons having health insurance; they don't pay for any medical service, so every requirement is recorded together with its price;
  • on the next n lines, the personal code (a 31-bit integer) and the name (27 characters or less, including space).

After the last person, the history of requirements follows. Every line is related to one requirement:

  • the personal code of the person who required medical service; for statistical purposes, the persons without health insurance are also recorded, but they pay for all medical service;
  • if the person is insured, the personal code is always followed by the price of medical service (a 31-bit integer);
  • if the person is not insured, and the price is present, you simply ignore the price.

The maximum length of every history line is 27 characters.

Output Specification

Using the template below, you have to display:

  • the total value of medical services, ignoring those which are related to persons without health insurance;
  • the personal code and the name of persons who required the maximum number of medical services, together with this maximum number;
  • the personal code and the name of persons who cumulated the maximum value of medical services, together with this maximum price;
  • every personal code must be preceded by one space, every list must be ordered alphabetically;
  • the number of persons without health insurance who required medical services.

Every two consecutive sections must be separated by an empty line. Follow the exact format of the sample output. Only the total value (first section) may exceed a 32-bit integer.

Sample Input

  1. 5
  2. 1 Arthur Conan Doyle
  3. 2 Edgar Alan Poe
  4. 3 George Sand
  5. 4 Marie Curie
  6. 5 Mireille Mathieu
  7. 1 6
  8. 2 7
  9. 3 10
  10. 1 6
  11. 2 6
  12. 3 10
  13. 1 6
  14. 2 7
  15. 4 18
  16. 6
  17. 7 5
  18. 8
  19. 9
  20. 6 4
  21. 7
  22. 8
  23. 6 3
  24. 7
download as text file

Output for Sample Input

  1. Total value of medical services: 76
  2. Maximum number of medical services: 3
  3.  1 Arthur Conan Doyle
  4.  2 Edgar Alan Poe
  5. Maximum cumulated value: 20
  6.  2 Edgar Alan Poe
  7.  3 George Sand
  8. Persons without insurance: 4
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019