Rosetta Problems

あみだくじ

https://atcoder.jp/contests/joi2009ho/tasks/joi2009ho_c