闫式dp分析法
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 110;
int f[N][N] , w[N][N];
int n;
int main() {
cin >> n;
for (int i = 1 ; i <= n ; i ++ )
for (int j = 1 ; j <= n ; j ++ ) cin >> w[i][j];
memset(f , 0x3f , sizeof f);
f[0][1] = f[1][0] = 0; // 开始的坐标初始化为0
for (int i = 1 ; i <= n ; i ++ )
for (int j = 1 ; j <= n ; j ++ ) f[i][j] = min(f[i - 1][j] , f[i][j - 1]) + w[i][j];
cout << f[n][n] << endl;
return 0;
}