Rosetta Problems

JOI 2006 本選 問題5

https://atcoder.jp/contests/joi2006ho/tasks/joi2006ho_e