Horse Carts
시간 제한1초메모리 제한2048 MB
마차 M대가 각각 무게 한도까지 보물 하나씩 운반할 때, 가져갈 수 있는 보물 가치 합의 최댓값을 구한다.
문제
You just found a cave filled with treasures (numbered from to ). Treasure has a weight of and a value of .
Luckily, you also bring horse carts (numbered from to ) to help you carry the treasures. Each cart can only carry one treasure; cart can only carry a treasure with weight at most .
Determine the maximum total value of treasures that you can take using your horse carts.
입력
The first line consists of two integers ().
Each of the next lines consists of two integers ().
The following line consists of integers ().
출력
Output a single integer representing the maximum total value of treasures that you can take using your horse carts.