CF839A.Arya and Bran
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.
At first, Arya and Bran have 0 Candies. There are n days, at the i-th day, Arya finds a__i candies in a box, that is given by the Many-Faced God. Every day she can give Bran at most 8 of her candies. If she don't give him the candies at the same day, they are saved for her and she can give them to him later.
Your task is to find the minimum number of days Arya needs to give Bran k candies before the end of the n-th day. Formally, you need to output the minimum day index to the end of which k candies will be given out (the days are indexed from 1 to n).
Print -1 if she can't give him k candies during n given days.
布兰和他的姐姐艾莉亚来自同一个家族。布兰非常喜欢糖果,因此艾莉亚打算给他一些糖果。
最初,艾莉亚和布兰都拥有 0 颗糖果。一共有 n 天,在第 i 天,艾莉亚会从“千面之神”赐予的一个盒子中找到 ai 颗糖果。每天她最多可以给布兰 8 颗她自己拥有的糖果;如果某天她没有把糖果全部给出,则剩余糖果将被保存下来,留待之后再给布兰。
你的任务是:求出艾莉亚在第 n 天结束前,至少需要多少天才能总共给布兰 k 颗糖果。形式化地说,你需要输出最小的天数下标(天数从 1 编号到 n),使得到该天结束时,已给出的糖果总数至少为 k。
若在给定的 n 天内无法给出 k 颗糖果,请输出 −1。
输入格式
The first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 10000).
The second line contains n integers _a_1, _a_2, _a_3, ..., a__n (1 ≤ a__i ≤ 100).
第一行包含两个整数 n 和 k(1 ≤ n ≤ 100,1 ≤ k ≤ 10000)。
第二行包含 n 个整数 a1,a2,a3,…,an(1 ≤ ai ≤ 100)。
输出格式
If it is impossible for Arya to give Bran k candies within n days, print -1.
Otherwise print a single integer — the minimum number of days Arya needs to give Bran k candies before the end of the n-th day.
如果Arya无法在 n 天内给Bran k 颗糖果,则输出 −1。
否则,输出一个整数——Arya在第 n 天结束前给Bran k 颗糖果所需的最少天数。
输入输出样例
输入#1
2 3 1 2
输出#1
2
输入#2
3 17 10 10 10
输出#2
3
输入#3
1 9 10
输出#3
-1
说明/提示
In the first sample, Arya can give Bran 3 candies in 2 days.
In the second sample, Arya can give Bran 17 candies in 3 days, because she can give him at most 8 candies per day.
In the third sample, Arya can't give Bran 9 candies, because she can give him at most 8 candies per day and she must give him the candies within 1 day.
在第一个样例中,Arya 可以在 2 天内给 Bran 3 颗糖果。
在第二个样例中,Arya 可以在 3 天内给 Bran 17 颗糖果,因为她每天最多能给他 8 颗糖果。
在第三个样例中,Arya 无法在 1 天内给 Bran 9 颗糖果,因为她每天最多只能给他 8 颗糖果,且必须在 1 天内完成赠送。
输入解题思路,AI测评打分。不知道怎么写?