Rosetta Problems

JOI 2006 予選 問題5

https://atcoder.jp/contests/joi2006yo/tasks/joi2006yo_e