[JSOI 200?] 小店购物

Brief description :

Cause the favorable concession... the local shop has been booming these days. The reason is customer could buy some item cheaper if she buy some one first, Give you the shopping list and those pair lists, Your task is to determine a order that minimize the total cost.
(You are not be able to buy the item which doesn't on the shopping list, even if it can help you reduce the total cost... )
ゆっくり読んでください ...