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

Разделы > Поиск > задача:


50866 - Buy the cheapest

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

Задачи раздела

• 50500 - Find Student
• 50786 - Top Question
• 50788 - Eight Puzzle
• 50504 - School contest
• 50787 - Expected Value
• 50859 - Low performance
• 50785 - Swimming Contest
• 50826 - Olive Containers
• 50866 - Buy the cheapest
• 50999 - Overlapping Trips
• 50507 - Sequential Numbers
• 50501 - The Highest Average
• 50434 - Row Min Subtraction
• 50980 - The smallest rectangle
• 50860 - Number of Student Certificates
• 50832 - Rock Paper Scissors Lizard ...
• 50834 - The train which leaves the f...

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

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

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

Buy the cheapest

It is time for economy. The director of the company has collected the price of items from two markets. They want to compare the prices and choose the cheaper one.

Question: Write a program that reads price of n items from two markets. And then, find the cheapest total price for m items.

Input specification
You will be first given two numbers: the number of items (n) and the number of items to search (m) where 0 ≤ m ≤ 5000 and 0 ≤ n ≤ 25,000. Then in the following n lines, you will be given information from two markets. Every line contains:

  • Product ID: an integer between 0 and 60,000.
  • Price of item from two markets: two integers between 1 and 10,000.
Then, the last m lines contain the IDs of products to buy.

Output specification: Show one integer: total minimum price for m items.
Note: If the item is not in the list, you don't buy it.

Sample Input I
10 5
3 942 754
15 937 372
17 762 202
8 617 940
10 744 528
20 836 330
21 594 236
6 491 448
12 719 18
23 281 954
8
3
12
21
16
Sample Output I
1625

Explanation: Here are the min prices for m products

Product IDMin Price
 Product # 8617
 Product # 3754
 Product # 1218
 Product # 21236
 Product # 16  Not in the list
Then, the total price is 1,625.



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

www.contester.ru