mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:08:47 +00:00
1018. 最低通行费
https://www.acwing.com/problem/content/submission/code_detail/8757904/
This commit is contained in:
parent
4b56a7a6b7
commit
538569394d
26
AcWing/1018/1018.cpp
Normal file
26
AcWing/1018/1018.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, w[105][105], f[105][105];
|
||||
|
||||
int main() {
|
||||
memset(f, 0x3f, sizeof(f));
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
cin >> w[i][j];
|
||||
}
|
||||
}
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
if (i == 1 && j == 1) {
|
||||
f[i][j] = w[i][j];
|
||||
} else {
|
||||
f[i][j] = min(f[i - 1][j], f[i][j - 1]) + w[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << f[n][n] << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user