SPOJ, Problem Code: sumtrian, Reducing time taken to solve.

Henrique Dante de Almeida hdante at gmail.com
Sun Jun 1 20:27:26 CEST 2008


On Jun 1, 10:25 am, Shriphani <shripha... at gmail.com> wrote:
> Hi,
>
> I was trying to solve the sumtrian problem in the SPOJ problem set
> (https://www.spoj.pl/problems/SUMTRIAN/) and this is the solution I
> submitted:http://pastebin.ca/1035867
>
> The result was, "Your solution from 2008-06-01 15:13:06 to problem
> SUMTRIAN, written in Python,
> has exceeded the allowed time limit."
>
> I suspect that the first portion of my solution which looks at the
> input, figures out the number of triangles and forms a list that
> contains lists containing each row of the triangle, is wrong. I am not
> too sure how to optimize it. I would appreciate help.
>
> Thanks,
> Shriphani Palakodety

 First, you have to write a correct algorithm. Notice that your code
doesn't correctly calculates the given sample input. Later, think
about optimization.



More information about the Python-list mailing list