| Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Ibrahim Mesecan.
 
 
   Buy the cheapestIt 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:
 
Then, the last m lines contain the IDs of products to buy.Product ID: an integer between 0 and 60,000.Price of item from two markets: two integers 
between 1 and 10,000.  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
 
Then, the total price is 1,625.| Product ID | Min Price |  | Product # 8 | 617 |  | Product # 3 | 754 |  | Product # 12 | 18 |  | Product # 21 | 236 |  | Product # 16 | Not in the list |  
 Для отправки решений необходимо выполнить вход.
 
 
 |