AcWing 1018. 最低通行费
原题链接
简单
作者:
兜兜里有糖
,
2024-12-20 18:06:19
,
所有人可见
,
阅读 1
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve()
{
int N;
cin >> N;
vector<vector<int>> dp(N + 1, vector<int>(N + 1, 1e9));
for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= N; j++)
{
cin >> dp[i][j];
}
}
for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= N; j++)
{
if (i == 1 && j == 1)
{
continue;
}
dp[i][j] += min(dp[i - 1][j], dp[i][j - 1]);
}
}
cout << dp[N][N] << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int _ = 1;
// cin >> _;
while (_--)
{
solve();
}
return 0;
}