怎么只有第三组数据通过了,错了两组数据,救救孩子,我也没看见这题有什么坑点啊

#include <stdio.h>
int dp[10001][1001]={0};
int w[10001]={0},v[10001]={0};
int max(int x,int y);
int main(){
	int n,t;
	scanf("%d %d",&n,&t);
	for(int i=1;i<=n;i++) scanf("%d %d",&w[i],&v[i]);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=t;j++){
			if(j<w[i]){
				dp[i][j]=dp[i-1][j];
			}else{
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			}
		}
	}
	printf("%d\n",dp[n][t]);
	return 0;
}
int max(int x,int y){
	return x>y?x:y;
}

0 comments

No comments so far...

Information

ID
13
Time
1000ms
Memory
256MiB
Difficulty
10
Tags
# Submissions
5
Accepted
2
Uploaded By