프로그램 명: coci_lopov
제한시간: 1 초

[문제 요약] 보석의 무게와 가격이 주어지고 , 최대 무게를 가져갈 수 있는 가방이 주어질 때 최대로 가져갈 수 있는 보석의 가격을 구하는 문제. 단, 가방에는 하나의 보석만 가져갈 수 있다.


The difficult economic situation in the country and reductions in government agricultural subsidy funding have caused Mirko to change his career again, this time to a thief. His first professional endeavour is a jewellery store heist.

The store contains N pieces of jewellery, and each piece has some mass Mi and value Vi. Mirko has K bags to store his loot, and each bag can hold some maximum mass Ci. He plans to store all his loot in these bags, but at most one jewellery piece in each bag, in order to reduce the likelihood of damage during the escape.

Find the maximum total jewellery value that Mirko can “liberate”.

입력

All numbers in the input are positive integers.

출력

The first and only line of output must contain the maximum possible total jewellery value.

입출력 예

input 

2 1 
5 10 
100 100 
11 

output 

10 

input 

3 2 
1 65 
5 23 
2 99 
10 
2

output 

164 

Clarification of the second example: Mirko stores the first piece of jewellery into the second bag and 
the third piece into the first bag
출처:coci/2013-2014/contest1

[질/답] [제출 현황] [푼 후(1)]
[ 채 점 ] [홈으로]  [뒤 로]