Sunday, January 18, 2009

Start ur journey here

Given an N x N matrix find the minimal path sum from the top left to the bottom right, by only moving to the right and down.
For example:






The minimum path is indicated in red and the sum is equal to 2427.


Limits
N<=100 Numbers in the matrix will be less than 1000. Input It is a multiple input problem. First line of Input will contain the value of N. In next N lines there will be N integers each. Input will be terminated by 0 as size. Output The output for each matrix should be a single line indicating the sum of the minimum path.
Sample Input:
5
131 673 234 103 18
201 96 342 965 150
630 803 746 422 111
537 699 497 121 956
805 732 524 37 331
0

Sample Output: 2427


The Solution is:

#include "iostream"
using namespace std;


For remaining wait upto 25th Jan.

No comments: