Teta
의견: 0
\(7^{th}\) round, March \(7^{th}\) 2015
You have found yourself in the role of a nice lady working as a cashier in a canteen. One of the multiple
reasons why the lady is considered nice by all students is because of her concern that you spend as less
as possible when visiting the canteen.
How does she do that? Well, the strategy is really simple. Various meals can be bought in the canteen
and their prices are known. Each day, a menu is offered. A menu includes 4 meals (usually it’s soup,
main course, side dish and dessert), but it’s price is less than or equal to the sum of prices of its
components. When the lady notices that you’d spend less money if she charged you with an entire
menu instead of individual things from the menu you took, then she will do so, and you will leave full
and with more money in your pocket.
You are standing in front of the cash register with your tray and want to know how much you have to
pay. Write a programme to determine it!
Please note: The lady can charge you with multiple menus if that comes out cheaper.
The first line of input contains the integer \(K\) (1 ⩽\(K\) ⩽20), the number of meals that can be bought
in the canteen. For simplicity’s sake, we will denote the meals with integers from 1 to \(K\).
The second line of input contains \(K\) integers, the \(i\)^{th} number representing the price of the meal denoted
with \(i\). The prices will be in range [1, 250].
The third line of input contains the integer \(X\) (1 ⩽\(X < 1000\)), the menu price.
The following line of input contains 4 integers, the labels of the meals from the menu, different from
each other.
The fourth line of input contains the integer \(T\) (1 ⩽\(T\) ⩽20), the number of meals on your tray.
The following line contains the list of meals you’ve taken. Not all meals on the tray have to be distinct,
it is possible to take multiple portions of a meal.
The first and only line of output must contain an integer, the cost of your meal.
7
10 6 8 9 4 5 3
14
1 2 3 4
5
1 3 4 6 7
22
6
12 5 7 8 9 3
14
4 3 1 2
5
1 2 1 6 6
32
평가 및 의견
Teta
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Teta