Codeforces Round #711 Bananas in a Microwave - Reading Comprehension

Solution:

Just a very simple DP. The hardest part is understanding the problem description and understanding the sample data.

We define $next$ to represent the corresponding index which is calculated according to $t$. For example $\lceil{i+x}\rceil$和$\lceil{i\cdot{x}}\rceil$。

For $cas$th operation. we have $ans[next]=cas$ and $used[next]=used[i]+1$ if $ans[i]\neq{-1}$ and $used[i]<y$. (Note that $used$ will be reset before each operation)

Scan and update $ans$与$used$. The scan order depends on if $next$ is larger than $i$ or not. May scan from left to right or scan from right to left.

That's all.

Code:

Submission #113021399 - Codeforces
Codeforces. Programming competitions and contests, programming community
DigitalOcean Referral Badge 蜀ICP备19018968号