Google Code Jam Japan 2011 予選問題B ref: http://qiita.com/items/3f04ade9bbaf68aae947