#include <iostream>
#include <vector>
using namespace std;
int minimumTotal(vector<vector<int> > &triangle) {
size_t size = triangle.size();
if (size <= 0) {
return 0;
}
int row = size - 1;
while (--row >= 0) {
int colSize = triangle[row].size();
int i = row + 1;
for (int j = 0; j < colSize; ++j) {
int min = triangle[i][j] < triangle[i][j+1] ?
triangle[i][j] : triangle[i][j+1];
triangle[row][j] += min;
}
}
return triangle[0][0];
}