#P10484. Maximum Gift Weight
Maximum Gift Weight
Maximum Gift Weight
GY is punished by having to help deliver gifts to a girl. He is sent by a mysterious figure who owns \(N\) extremely heavy gifts. Fortunately, GY has enormous strength and can carry any set of gifts in one move provided the total weight does not exceed \(w\). However, after seeing the gifts, GY regrets his task and wants to move the heaviest possible load in one go. Your task is to help him choose a subset of gifts such that their total weight is maximized without exceeding \(w\).
inputFormat
The input consists of two lines. The first line contains two integers (N) and (w) separated by a space. The second line contains (N) integers representing the weights of the gifts.
outputFormat
Output a single integer representing the maximum total weight that GY can move in one go without exceeding (w).
sample
3 10
5 7 3
10