Project Euler 456

http://projecteuler.net/index.php?section=problems&id=456

61着。13秒。
O(NlogN)の解法がすぐに思いついたが、なかなかデバッグが進まなかった。
人工的で簡単な例を使えばよかった。