CF 839A - Arya and Bran
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 ai 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天,艾莉亚在盒子里发现了千面之神赐予的糖果。 她每天最多可以给布兰 8 颗糖果。 如果她当天没有给他糖果,这些糖果就会为她保留,她可以稍后再给他。
你的任务是找出在第 n 天结束之前艾莉亚需要给布兰克糖果的最少天数。 形式上,您需要输出将发出 k 颗糖果的最小天数索引(天数索引从 1 到 n)。
如果她在给定的 n 天内无法给他 k 颗糖果,则输出 -1。
-------------------------------------------------------
用两个半两一次存储每次可以给出的糖果,以及每次自己还剩下的糖果,依次遍历即可;