0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 16:36:28 +00:00

1287. 最低通行费

http://ybt.ssoier.cn:8088/statusx.php?runidx=15577831
This commit is contained in:
Baoshuo Ren 2022-04-03 09:03:31 +08:00
parent 1dfbb8ac7e
commit 1957f776aa
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

33
ybt/1287/1287.cpp Normal file
View File

@ -0,0 +1,33 @@
#include <cstring>
#include <iostream>
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;
}