>>294
これ ABC319
https://atcoder.jp/contests/abc319/tasks/abc319_d