Stealing Snacks from Juniors
InterviewTime limit1sMemory limit256 MB
Choose a subset of snacks whose total fullness reaches M, minimizing total satisfaction, or report that it is impossible.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Greedy, Sorting
- Solved
- No attempts yet
Problem
Seungyeop is the most senior soldier in his unit, a sergeant one week away from discharge. Nobody on the base can stop him.
His hobby is opening his juniors' footlockers while they are out on work detail or guard duty and stealing their snacks.
Seungyeop has a fixed 'fullness threshold' , the amount of fullness at which he feels satisfied, and his goal is to feel worth of fullness by eating snacks. If he cannot reach at least fullness, he gets angry.
Wondering whose snacks to steal, he orders Hyeoncheol, his most docile junior, to bring him enough snacks to fill him up.
Hyeoncheol resents Seungyeop for bullying the other juniors, so he plans to pick only the snacks Seungyeop likes the least.
Seungyeop has rated how tasty every snack sold at the PX is, giving each a satisfaction score.
Help Hyeoncheol, who is suffering, and compute the minimum satisfaction Seungyeop can get while filling his stomach!
Input
The first line gives the number of juniors (1 ≤ ≤ 100) and Seungyeop's fullness threshold (1 ≤ ≤ 100,000), separated by a space.
The next lines each give the fullness (1 ≤ ≤ 1,000) and satisfaction (1 ≤ ≤ 1,000) obtained by stealing that junior's snack, separated by a space.
Output
On the first line, print the minimum satisfaction Seungyeop can get while reaching the fullness threshold.
If Seungyeop cannot reach the fullness threshold with snacks, print “죄송합니다 한승엽 병장님” on one line.