0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 20:16:29 +00:00
OI-codes/ybt/1287/1287.cpp

34 lines
593 B
C++

#include <iostream>
#include <cstring>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 105;
int n, g[N][N], f[N][N];
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> g[i][j];
}
}
memset(f, 0x3f, sizeof(f));
f[0][1] = f[1][0] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
f[i][j] = std::min(f[i - 1][j], f[i][j - 1]) + g[i][j];
}
}
cout << f[n][n] << endl;
return 0;
}