10pts,求调
查看原帖
10pts,求调
1331246
Guanguplussss楼主2025/1/5 21:00

求debug

#include<bits/stdc++.h>
using namespace std;
int f,v,a[1001][1001],dp[1001][1001];
void dfs(int x,int y){
	if(x==0){
		return;
	}
	while(dp[x][y]==dp[x][y-1]){
		y--;
	}
	dfs(x-1,y-1);
	cout<<y<<' ';
} 
int main(){
	cin>>f>>v;
	for(int i=1;i<=f;i++){
		for(int j=1;j<=v;j++){
			cin>>a[i][j];
			//dp[i][j]=INT_MIN;
		}
	} 
	for(int i=1;i<=f;i++){
		for(int j=i;j<=i+v-f;j++){
			dp[i][j]=max(max(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1]+a[i][j]);
		}
	}
	cout<<dp[f][v]<<endl;
	dfs(f,v);
	return 0;
}

2025/1/5 21:00
加载中...