topCoder 1, not a good solution