Knapsack
Easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Vasya is going to hike with fellow programmers and decided to take a responsible approach to the choice of what he will take with him. Vasya has things that he could take with him in his knapsack. Every thing weighs kilogram. Things have different "usefulness" for Vasya.
The hiking is going to be very long, so Vasya would like to carry a knapsack of weight no more than kilo.
Help him to determine the total "usefulness" of things in his knapsack if the weight of backpack can be no more than kilo.
Input
The first line contains integers и . The second line contains integers — the "usefulness" for each thing.
Output
Print the total "usefulness" of things that Vasya can take with him.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 3K
Acceptance rate 51%