萌新求助
查看原帖
萌新求助
677581
_Glassy_Sky_楼主2023/8/25 22:17
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e2 + 5;
int a[MAXN][MAXN], dp[MAXN];
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i < n; i ++)
		for(int j = i; j < n; j ++)
			cin >> a[i][j];
	memset(dp, 1e9, sizeof(dp));
	for(int i = n - 1; i >= 1; i --)
		for(int j = i; j < n; j ++)
			dp[i] = min(dp[i], a[i][j] + dp[j]);
	cout << dp[1];
	return 0;
}

2023/8/25 22:17
加载中...