public static void main(String[] args) throws FileNotFoundException {
        
        long start = System.currentTimeMillis();
        Scanner sc = new Scanner(new BufferedReader(new FileReader("C://matrix.txt")));
        int [][] mat = new int[80][80];
        int [] sol = new int[80];
        String[] tmp;
        int result = Integer.MAX_VALUE;
        
        //read matrix from file to 2d array
        for(int i = 0; i < 80; i++){
            tmp = sc.next().split(",");
            
            for(int j = 0; j < tmp.length; j++){
                mat[i][j] = Integer.parseInt(tmp[j]);
            }
        }
        
        //initialize the solution vector with the last column
        for(int i = 0; i < 80; i++)
            sol[i] = mat[i][79];
        
        for(int i = 78; i > -1; i--){
            
            sol[0] += mat[0][i];
            
            //traverse down
            for(int j = 1; j < 80; j++){
                sol[j] = Math.min(sol[j-1] + mat[j][i], sol[j] + mat[j][i]);
            }
            
            //traverse up
            for(int j = 78; j > -1; j--){
                sol[j] = Math.min(sol[j], sol[j+1] + mat[j][i]);
            }
        }
        
        for(int i = 0; i < sol.length; i++){
            if(sol[i] < result)
                result = sol[i];
        }
        
        long stop = System.currentTimeMillis();
        System.out.println("Result: " + result);
        System.out.println("Execution time: " + (stop- start));
    }