mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-28 12:31:59 +00:00
parent
1dfbb8ac7e
commit
1957f776aa
33
ybt/1287/1287.cpp
Normal file
33
ybt/1287/1287.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user