公式

C - 花壇の水やり / Watering the Flower Bed 解説 by kyopro_friends


ABC111Cとほとんど同じ問題であるため、解説はそちらに譲ります

https://atcoder.jp/contests/awc0111/editorial/22247