Wednesday, January 1, 2014

SPOJ 237. Sums in a Triangle

Here is the problem statement
http://www.spoj.com/problems/SUMITR/

There is not much to say about this problem. The idea is simple , we just keep an array of answers , the we loop over it and update the current element with the best answer ( it would be max( a[i-1][j-1]+a[i][j],a[i-1][j]+a[i][j]) ) The drill ios the source limit. You need to preserver as much as possible . Avoid using many enters, spaces. Don't keep variables which you are not going to use. Make sure to check my source code. Its only 2 lines :D The first is #include <iostream> and the second on is full of operations. Its a long line :)

       FULL SOURCE CODE

No comments:

Post a Comment