HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Sorting and sequences > problem:


50750 - Service Time - 2

Guest
• Review clarifications (1)

Section problems

• 50991 - Intersecting Circles
• 50513 - Climbing Up the Stairs
• 50744 - The Smallest Perimeter
• 51002 - The most successful classes
• 50743 - Total Scholarships Discount
• 50847 - The first m trains to leave
• 50984 - Top m hardworking employees
• 50740 - Service Time - 1
• 50750 - Service Time - 2
• 50752 - Student Groups
• 50754 - Team Standings
• 50751 - The biggest Minute
• 50998 - CEN112 Homework, quiz av...
• 50804 - Marathon
• 50835 - Club Presidency
• 50747 - Safe boxes against thieves
• 50742 - King Arthur II

Feedback

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

Time limit 4000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Serving Time - 2

Question: Bank Asia wants to change their client serving numerator system. In this new system, the people will be assigned a priority according to their own client priority and priority according to the operation they want to have. They are also assigned an approximate serving time, according to operation they have.

Write a program that is going to read the information for the currently waiting people. Then, your program will find out the total waiting time for new arrived clients (including their own service time).

Input specification: In the first line, you are given an integer (n), the number of people currently waiting in the queue where 1 ≤ n ≤ 50000. Then, each of the following n lines contain information for a client. In every client information line you are given

  • The name of person: Names may be composed of only English letters and several strings ending with a semicolon ';'.
  • The priority of the client: an integer where 1 ≤ Priority ≤ 10000;
  • Serving time: an integer between 0 and 50
After that, you are given another integer (m) the number of new of newly arrived clients where 1 ≤ m ≤ 25000. Each of the following m lines contain information of a new client.

Output specification
Show the total waiting time for all new clients.
Note: The highest priority person is served first. If two people have the same priority, then, the person who has less service time is served first. If they have same priority and same service time, then they are served in ascending name order.

 Sample Input I     Sample Output I   
 5
 Corey Cecil Hines; 6 4
 Leonard Afrim Osmani; 8 9
 Ervin Dervishi; 14 8
 Carlos Estrada; 3 6
 Anjeza Dardani; 11 5
 2
 Erion Aurini; 8 4
 Sami Agolli; 11 5
 40

Explanation: There are two people who have higher or equal priority with Sami Agolli:

  • It takes 8 minutes to serve Ervin Dervishi.
  • It takes 5 minutes to serve Anjeza Dardani
  • It takes 5 minutes to serve for himself
That makes 18 minutes waiting time for Sami Agolli.

Similarly Mr. Aurini waits for the same people, plus

  • and, it takes 4 minutes to serve for himself.
That makes 22 minutes waiting time for Mr. Aurini. Then, the total waiting time is 22+18=40 minutes for all new clients.
Для отправки решений необходимо выполнить вход.

www.contester.ru