RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00352

Teta

Unrated 레이팅 미적용
난이도
1s
시간 제한
64MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 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.

예제 1
입력
7
10 6 8 9 4 5 3
14
1 2 3 4
5
1 3 4 6 7
출력
22
예제 2
입력
6
12 5 7 8 9 3
14
4 3 1 2
5
1 2 1 6 6
출력
32
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2014/2015 Contest 7

평가 및 의견

Teta

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Teta

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8