Cooking Steaks
시간 제한1초메모리 제한2048 MB
각 익힘 정도마다 있는 스테이크 수와 주문 수가 주어질 때, 한 번에 하나만 조리하는 조건에서 모든 주문을 처리하는 최소 총 조리 시간을 구하거나 불가능하면 -1을 출력한다.
문제
Morgan is a chef in a steak house. In his steak house, a steak can have level of doneness, numbered from to . Currently, Morgan has steaks of doneness level ready in his steak house.
There are orders of steaks with doneness level that need to be fulfilled. Morgan can cook the steaks in order to match the doneness level. For each , it takes Morgan seconds to cook a steak from doneness level to . Note that Morgan can only cook one steak at a time.
Morgan asks for your help to find the minimum total time to fulfil all orders, or tell him that the orders are impossible to fulfil.
입력
Input begins with an integer (). The next line contains integers () representing the time required to cook a steak of doneness level to . The next line contains integers () representing the number of steaks with doneness level . The next line contains integers () representing the number of orders for a steak with doneness level .
출력
If all orders can be fulfilled, then output an integer in a single line representing the minimum total time to fulfill all orders. Otherwise, output -1 in a single line.