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

歡迎光臨散文網(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ó)家法律
屯昌县| 屏边| 独山县| 赤城县| 河南省| 深圳市| 芜湖县| 吉首市| 阳西县| 灵川县| 洪江市| 镇平县| 东至县| 黎城县| 丰宁| 巧家县| 扶沟县| 胶州市| 翁牛特旗| 红桥区| 元阳县| 泸溪县| 论坛| 张家界市| 页游| 乌拉特前旗| 铜鼓县| 中阳县| 罗甸县| 商河县| 南皮县| 常宁市| 武安市| 增城市| 南溪县| 壶关县| 盖州市| 蓬溪县| 五峰| 西乌珠穆沁旗| 怀远县|