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]标记。