[문제 요약] 세트 메뉴와 단품 메뉴 가격이 주어질때 적당히 조합해서 먹을때의 최소의 비용을 구하는 것입니다. 1번째 라인 K : 판매하는 메뉴의 가짓수, 각 메뉴는 1~K 까지의 번호를 부여받음 2번째 라인 : 1~K 까지 각 메뉴의 가격 3번째 라인 X : 세트 메뉴의 가격, 세트는 4개의 메뉴로 구성 4번째 라인 : 세트 메뉴를 구성하고 있는 서로 다른 4개의 메뉴 번호 5번째 라인 T : 먹고자 하는 메뉴의 숫자 6번째 라인 : 먹고자 하는 메뉴의 번호 예제1 --------------------- 입력 7 10 6 8 9 4 5 3 14 1 2 3 4 5 1 3 4 6 7 출력 22 세트메뉴(14) + 6번메뉴(5) + 7번메뉴(3) = 22 --------------------- 예제2 --------------------- 입력 6 12 5 7 8 9 3 14 4 3 1 2 5 1 2 1 6 6 출력 32 세트메뉴(14) + 1번메뉴(12) + 6번메뉴2개(3*2) = 32
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.
입력 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 Clarification of the first example: You took meals 1, 3 and 4 that are part of a menu and the lady will charge you with an entire menu. Meals 6 and 7 aren’t part of a menu, so you pay their full price. Clarification of the second example: You took two portions of meal 1 (Wiener Schnitzel), but the lady will charge you one portion along with one portion of meal 2 as a menu, but will charge the other portion separately (because it doesn’t pay off to charge it as a second menu). You took two juices (meal 6), but you pay for them separately because they are not a part of the menu.
출처:2013-2014 contest7 1/6 요약:hyowoo