麻烦大佬找错误
查看原帖
麻烦大佬找错误
1274811
MaskedFools_Sparkle楼主2024/5/25 15:19

die码
麻烦各位了

#include<bits/stdc++.h>
#define int long long
using namespace std;

struct tag
{
	int data=INT_MAX;
	vector<int> num;
};

const int N=100;
int est[N][N];
int flo_num,vas_num;
tag dp[N][N];

signed main()
{
	cin>>flo_num>>vas_num;
	for(int times1=1;times1<=flo_num;times1++)
		for(int times2=1;times2<=vas_num;times2++)
			cin>>est[times1][times2];
	
	for(int times=0;times<=vas_num;times++)
		dp[0][times].data=0;
	
	for(int times1=1;times1<=flo_num;times1++)
		for(int times2=times1;times2<=vas_num-(flo_num-times1);times2++)
		{
			dp[times1][times2]=dp[times1][times2-1];
			if(dp[times1-1][times2-1].data+est[times1][times2]>dp[times1][times2].data)
			{
				dp[times1][times2].data=dp[times1-1][times2-1].data+est[times1][times2];
				dp[times1][times2].num=dp[times1-1][times2-1].num;
				dp[times1][times2].num.push_back(times2);
			}
		}
	
	cout<<dp[flo_num][vas_num].data<<endl;
	for(int times=0;times<flo_num;times++)
	{
		cout<<dp[flo_num][vas_num].num[times]<<" ";
	}
}
2024/5/25 15:19
加载中...