CF830C.Bamboo Partition

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vladimir wants to modernize partitions in his office. To make the office more comfortable he decided to remove a partition and plant several bamboos in a row. He thinks it would be nice if there are nn bamboos in a row, and the ii-th from the left is aia_i meters high.

Vladimir has just planted nn bamboos in a row, each of which has height 00 meters right now, but they grow 11 meter each day. In order to make the partition nice Vladimir can cut each bamboo once at any height (no greater that the height of the bamboo), and then the bamboo will stop growing.

Vladimir wants to check the bamboos each dd days (i.e. dd days after he planted, then after 2d2d days and so on), and cut the bamboos that reached the required height. Vladimir wants the total length of bamboo parts he will cut off to be no greater than kk meters.

What is the maximum value dd he can choose so that he can achieve what he wants without cutting off more than kk meters of bamboo?

弗拉基米尔希望改造办公室的隔断。为了让办公室更加舒适,他决定拆除一道隔断,并在一行中种植若干竹子。他觉得如果一行中有 nn 根竹子,且从左往右第 ii 根竹子的高度恰好为 aia_i 米,那就非常美观。

弗拉基米尔刚刚在一排种下了 nn 根竹子,每根竹子当前高度均为 00 米,但它们每天均长高 11 米。为了使隔断达到理想效果,弗拉基米尔可以对每根竹子至多修剪一次(剪裁位置不能高于该竹子当前高度),此后该竹子将停止生长。

弗拉基米尔计划每隔 dd 天检查一次竹子(即在种下后第 dd 天、第 2d2d 天、……时进行检查),并对已达到目标高度的竹子进行修剪。他希望所有被剪下的竹子部分的总长度不超过 kk 米。

请问:满足上述要求的前提下,弗拉基米尔所能选择的最大 dd 值是多少?

输入格式

The first line contains two integers nn and kk (1≤n≤1001 \le n \le 100, 1≤k≤10111 \le k \le 10^{11}) — the number of bamboos and the maximum total length of cut parts, in meters.

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \le a_i \le 10^9) — the required heights of bamboos, in meters.

第一行包含两个整数 nn 和 kk(1≤n≤1001 \le n \le 100,1≤k≤10111 \le k \le 10^{11})—— 分别表示竹子的数量以及被截去部分的总长度上限(单位:米)。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \le a_i \le 10^9)—— 表示每根竹子所需达到的高度(单位:米)。

输出格式

Print a single integer — the maximum value of dd such that Vladimir can reach his goal.

输出一个整数——即 Vladimir 能够达成目标的最大 dd 值。

输入输出样例

  • 输入#1

    3 4
    1 3 5

    输出#1

    3
  • 输入#2

    3 40
    10 30 50

    输出#2

    32

说明/提示

In the first example Vladimir can check bamboos each 33 days. Then he will cut the first and the second bamboos after 33 days, and the third bamboo after 66 days. The total length of cut parts is 2+0+1=32+0+1=3 meters.

在第一个例子中,弗拉基米尔可以每 33 天检查一次竹子。这样,他将在 33 天后砍掉第一根和第二根竹子,66 天后砍掉第三根竹子。被砍下的部分总长度为 2+0+1=32+0+1=3 米。

输入解题思路,AI测评打分。不知道怎么写?

首页