最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

CF 839A - Arya and Bran

2023-06-28 14:15 作者:您是打尖兒還是住店呢  | 我要投稿

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.

-----------------------------------------------------------------------------

布蘭和他的姐姐艾莉亞來(lái)自同一所房子。 布蘭非常喜歡糖果,所以艾莉亞要給他一些糖果。


起初,艾莉亞和布蘭有 0 顆糖果。 有n天了,在第i天,艾莉亞在盒子里發(fā)現(xiàn)了千面之神賜予的糖果。 她每天最多可以給布蘭 8 顆糖果。 如果她當(dāng)天沒(méi)有給他糖果,這些糖果就會(huì)為她保留,她可以稍后再給他。


你的任務(wù)是找出在第 n 天結(jié)束之前艾莉亞需要給布蘭克糖果的最少天數(shù)。 形式上,您需要輸出將發(fā)出 k 顆糖果的最小天數(shù)索引(天數(shù)索引從 1 到 n)。


如果她在給定的 n 天內(nèi)無(wú)法給他 k 顆糖果,則輸出 -1。

-------------------------------------------------------

用兩個(gè)半兩一次存儲(chǔ)每次可以給出的糖果,以及每次自己還剩下的糖果,依次遍歷即可;


CF 839A - Arya and Bran的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
南部县| 南漳县| 武平县| 四会市| 阿图什市| 寿宁县| 双牌县| 闸北区| 盐边县| 容城县| 大关县| 桓台县| 铜陵市| 襄垣县| 阳城县| 湛江市| 曲阜市| 桂平市| 西华县| 昆明市| 大足县| 石嘴山市| 德昌县| 平顶山市| 读书| 壤塘县| 县级市| 昆山市| 雷山县| 屏东市| 沙坪坝区| 瑞丽市| 青海省| 北票市| 南召县| 旅游| 河曲县| 庆云县| 武功县| 富宁县| 迁西县|