题库练习 Coffee and Coursework (Easy version)
← 上一题 下一题 →

A12434 | Coffee and Coursework (Easy version)

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

The only difference between easy and hard versions is the constraints.

Polycarp has to write a coursework. The coursework consists of $m$ pages.

Polycarp also has $n$ cups of coffee. The coffee in the $i$ -th cup has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He can drink cups in any order. Polycarp drinks each cup instantly and completely (i.e. he cannot split any cup into several days).

Surely, courseworks are not usually being written in a single day (in a perfect world of Berland, at least). Some of them require multiple days of hard work.

Let's consider some day of Polycarp's work. Consider Polycarp drinks $k$ cups of coffee during this day and caffeine dosages of cups Polycarp drink during this day are $a_{i_1}, a_{i_2}, \dots, a_{i_k}$ . Then the first cup he drinks gives him energy to write $a_{i_1}$ pages of coursework, the second cup gives him energy to write $max(0, a_{i_2} - 1)$ pages, the third cup gives him energy to write $max(0, a_{i_3} - 2)$ pages, ..., the $k$ -th cup gives him energy to write $max(0, a_{i_k} - k + 1)$ pages.

If Polycarp doesn't drink coffee during some day, he cannot write coursework at all that day.

Polycarp has to finish his coursework as soon as possible (spend the minimum number of days to do it). Your task is to find out this number of days or say that it is impossible.

输入格式

The first line of the input contains two integers $n$ and $m$ ( $1 \le n \le 100$ , $1 \le m \le 10^4$ ) — the number of cups of coffee and the number of pages in the coursework.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le 100$ ), where $a_i$ is the caffeine dosage of coffee in the $i$ -th cup.

输出格式

If it is impossible to write the coursework, print -1. Otherwise print the minimum number of days Polycarp needs to do it.

输入输出样例

输入 #1
5 8
2 3 1 1 2
输出 #1
4
输入 #2
7 10
1 3 4 2 1 4 2
输出 #2
2
输入 #3
5 15
5 5 5 5 5
输出 #3
1
输入 #4
5 16
5 5 5 5 5
输出 #4
2
输入 #5
5 26
5 5 5 5 5
输出 #5
-1
C++ 编辑器
输入
输出