UVa 341 solution - time limit - bug somewhere