P26355 [AtCoder] haruki's Awakening
省选
题目描述

Problem Description

haruki is famous for being weak in the morning. haruki has $ n $ alarm clocks in his house, and the volume of the $ i $ th alarm clock is $ a_i $.

haruki will not wake up unless the total volume of the ringing alarm clocks is at least $ m $. However, setting too many alarm clocks can be too noisy and bother the neighbors.

Therefore, find the total volume when the alarm clocks are chosen such that the total volume is at least $ m $ and is minimized.

Input Format

The input is given in the following format:

$ n $ $ m $ $ a_1 $ $ a_2 $ $ ... $ $ a_n $

  • The first line contains an integer $ n $ ($1 \leq n \leq 50$), representing the number of alarm clocks, and an integer $ m $ ($1 \leq m \leq 10{,}000$), representing the minimum volume to wake up.
  • The following $ n $ lines contain an integer $ a_i $ ($1 \leq a_i \leq 10{,}000$), representing the volume of each alarm clock.

Output Format

Output the total volume when the alarm clocks are chosen such that the total volume is at least $ m $ and is minimized.

If the total volume does not reach $ m $, output -1.

End with a newline and do not include any extra characters or blank lines.

Sample Input and Output

Sample Input #1

3 30
25
10
23

Sample Output #1

33

Sample Input #2

4 101
10
20
30
40

Sample Output #2

-1

Notes/Hints

None

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 30 25 10 23
样例输出
33