D - Sushisushi Conveyor Belt Sushi Restaurant Editorial
by
ychangseok
First, let’s find the maximum number of sushi pieces that can be eaten from each cell. Let \(cnt_i\) denote the maximum number of sushi pieces that can be eaten from the \(i\)th cell, then \(cnt_i\) can be calculated through simulation. Using cumulative sums, we can calculate the satisfaction gained when \(i\) sushi pieces are eaten from each cell, starting from the top.
Therefore, we can use a greedy algorithm to find the maximum satisfaction that can be obtained from each cell. By summing the maximum satisfaction obtainable from each cell, we can solve the problem.
Be careful in cases where it is optimal not to eat any sushi from a particular cell, or when \(K_i = 0\).
posted:
last update:
