B. Napoleon Cake

这篇博客介绍了如何制作拿破仑蛋糕,并将其与编程问题相结合。作者Arkady遵循传统想要制作煎饼,但意识到这样做需要在特定IT公司工作,于是转向制作拿破仑蛋糕。在制作过程中,每叠加一层蛋糕都会加入一定量的奶油,导致蛋糕顶部的若干层被奶油浸湿。博客详细解释了问题的背景、题意,以及如何通过编程解决这个问题。给出的代码用于判断每层蛋糕是否被奶油覆盖。
摘要由CSDN通过智能技术生成

B. Napoleon Cake

原题链接:

https://codeforces.com/contest/1501/problem/B

题意:

This week Arkady wanted to cook some pancakes (to follow ancient traditions) and make a problem about that. But then he remembered that one can’t make a problem about stacking pancakes without working at a specific IT company, so he decided to bake the Napoleon cake instead.

To bake a Napoleon cake, one has to bake n dry layers first, and then put them on each other in one stack, adding some cream. Arkady started with an empty plate, and performed the following steps n times:

place a new cake layer on the top of the stack;
after the i-th layer is placed, pour ai units of cream on top of the stack.
When x units of cream are poured on the top of the stack, top x layers of the cake get drenched in the cream. If there are less than x layers, all layers get drenched and the rest of the cream is wasted. If x=0, no layer gets drenched.

在这里插入图片描述

题解:

题意中说从空盘开始每次加一层蛋糕并且每次都往上倒a[i]的奶油,
加到层蛋糕每次都有相应的奶油倒上去,最后输出每一层是否被倒上奶油。

思路:从最顶层开始往下找,i指针从上到下依次找,j指针每次取i和j更下面的如果j>i-a[i],则下一层会被奶油涂上j–,并且a[j]标记。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值