HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50999 - Overlapping Trips

Guest
• Review clarifications (1)

Volume problems

• 50823 - Secret Number
• 50853 - Parking Place
• 50496 - Falling Bricks
• 50802 - Comparing Exams
• 50785 - Swimming Contest
• 50866 - Buy the cheapest
• 50517 - Confusion Matrix
• 50515 - Lines - Revisited
• 50999 - Overlapping Trips
• 50507 - Sequential Numbers
• 50449 - The biggest result
• 50442 - Polynomial Addition
• 50434 - Row Min Subtraction
• 50870 - ZScore normalization
• 50869 - Birthday Celebration
• 50821 - Derivative of an array
• 50513 - Climbing Up the Stairs

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 Ibrahim Mesecan.

Overlapping Trips

The school administration has just realized that there are two activities overlapping. So, the administration wants to see the list of participants and collusions. When collecting the lists, organizers have collected student ID, class information and the amount of money given for the activity.

Question: Write a program that reads the participants list of two programs then print the number of people participating to the activities. If a person is in two activities, he chooses the cheaper one. If the prices are also the same, the person chooses the first activity if his/her id is odd, the second activity otherwise.

Input specification: In the first line, you will be given two integers: the number of people participating to the first (n) and the second (m) activities. Then, the following n lines contain the people information for the first activity. And the next m lines, contain the people information for the second activity where each line contains:

  • Student ID: at most 8 digit integer
  • Class information is at most 8 char string containing alpha-numeric chars
  • amount: a floating point number not greater than 1e7
and 1 ≤ m ≤ n ≤ 30,000.

Output specification: Show two integers.

Sample Input
4 5
3 CEN1 20
4 CEN1 28
7 CEN2 10
12 ECE1 21
2 ECE1 19
4 CEN2 10
7 CEN2 15
11 ECE2 21
12 ECE1 20
Sample Output
2 4

Explanation: People with the IDs 4, 7 and 12 are in two activity lists. ID 7 chooses the first activity, 4 and 12 chooses the second activity. Thus, there are 2 people in the first activity and there are 4 people in the second activity.



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

www.contester.ru