305977: CF1118D1. Coffee and Coursework (Easy version)

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Coffee and Coursework (Easy version)

题意翻译

#### 题意 Polycarp 有 $n$ 杯咖啡,每一杯咖啡都有一个对应的权值 $a_i$。 同时,他还有 $m$ 个任务: 每一天可以选择喝任意杯咖啡 $i_1,i_2,i_3,\cdots,i_{k-1},i_k$。其中,喝掉第一杯可以完成第 $a_{i_1}$ 个任务,喝掉第二杯可以完成第 $\max\{a_{i_2}-1,0\}$ 个任务……喝掉第 $k$ 杯可以完成第 $\max\{a_{i_k}-k+1,0\}$ 个任务 。 Polycarp 想知道,至少需要多少天他才能完成这所有的 $m$ 个任务;如若他不能完成,则输出 $-1$。 #### 输入 第一行,两个整数 $n$ 和 $m$; 第二行,共 $n$ 个整数,第 $i$ 个整数表示第 $i$ 杯咖啡的权值 $a_i$。 #### 输出 共一行,若可以完成所有任务,输出最少所需要的天数;反之,输出 $-1$。 #### 数据范围 $1 \leq n \leq 100 , 1 \leq m \leq n^4 , 1 \leq a_i \leq 100$

题目描述

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

说明

In the first example Polycarp can drink fourth cup during first day (and write $ 1 $ page), first and second cups during second day (and write $ 2 + (3 - 1) = 4 $ pages), fifth cup during the third day (and write $ 2 $ pages) and third cup during the fourth day (and write $ 1 $ page) so the answer is $ 4 $ . It is obvious that there is no way to write the coursework in three or less days in this test. In the second example Polycarp can drink third, fourth and second cups during first day (and write $ 4 + (2 - 1) + (3 - 2) = 6 $ pages) and sixth cup during second day (and write $ 4 $ pages) so the answer is $ 2 $ . It is obvious that Polycarp cannot write the whole coursework in one day in this test. In the third example Polycarp can drink all cups of coffee during first day and write $ 5 + (5 - 1) + (5 - 2) + (5 - 3) + (5 - 4) = 15 $ pages of coursework. In the fourth example Polycarp cannot drink all cups during first day and should drink one of them during the second day. So during first day he will write $ 5 + (5 - 1) + (5 - 2) + (5 - 3) = 14 $ pages of coursework and during second day he will write $ 5 $ pages of coursework. This is enough to complete it. In the fifth example Polycarp cannot write the whole coursework at all, even if he will drink one cup of coffee during each day, so the answer is -1.

Input

题意翻译

#### 题意 Polycarp 有 $n$ 杯咖啡,每一杯咖啡都有一个对应的权值 $a_i$。 同时,他还有 $m$ 个任务: 每一天可以选择喝任意杯咖啡 $i_1,i_2,i_3,\cdots,i_{k-1},i_k$。其中,喝掉第一杯可以完成第 $a_{i_1}$ 个任务,喝掉第二杯可以完成第 $\max\{a_{i_2}-1,0\}$ 个任务……喝掉第 $k$ 杯可以完成第 $\max\{a_{i_k}-k+1,0\}$ 个任务 。 Polycarp 想知道,至少需要多少天他才能完成这所有的 $m$ 个任务;如若他不能完成,则输出 $-1$。 #### 输入 第一行,两个整数 $n$ 和 $m$; 第二行,共 $n$ 个整数,第 $i$ 个整数表示第 $i$ 杯咖啡的权值 $a_i$。 #### 输出 共一行,若可以完成所有任务,输出最少所需要的天数;反之,输出 $-1$。 #### 数据范围 $1 \leq n \leq 100 , 1 \leq m \leq n^4 , 1 \leq a_i \leq 100$

加入题单

算法标签: