Rosetta Problems

壊れた電車

https://atcoder.jp/contests/code-festival-2015-quala/tasks/codefestival_2015_qualA_d