已改正~
错误在代码中标出。
```cpp
@[hiuseues](/space/show?uid=47842)
#include <cstdio>
int tot,choice,dp[10001]={0},time[10001],value[10001];//数组开太小辣
inline int max(int a,int b){return (a>b)?a:b;}
int main(){
scanf("%d%d",&tot,&choice);
for(int i=1;i<=choice;i++) scanf("%d%d",&time[i],&value[i]);
for(int i=1;i<=choice;i++)
for(int t=tot;t>=time[i];t--) //这里应该是t--,而不是tot--,楼主有点马虎了...
dp[t]=max(dp[t],dp[t-time[i]]+value[i]);//帮你删除了一个奇怪的输出
printf("%d\n",dp[tot]);
}
```
by Akashicw @ 2017-10-27 20:55:23
艾特格式又错了...
@[hiuseues](/space/show?uid=47842)
by Akashicw @ 2017-10-27 20:55:54
貌似是有点粗心了
谢大佬
by middle_set @ 2017-10-27 21:56:56
orz少加了取地址符
```cpp
#include <cstdio>
int t,m,dp[1001]={0},cost[1001],value[1001];
inline int max(int a,int b){return (a>b)?a:b;}
int main(){
scanf("%d%d",&t,&m);
for(int i=1;i<=m;i++) scanf("%d%d",&cost[i],&value[i]);
for(int i=1;i<=m;i++) for(int j=t;j>=cost[i];j--) dp[j]=max(dp[j],dp[j-cost[i]]+value[i]);
printf("%d\n",dp[t]);
}
```
by middle_set @ 2017-10-29 09:47:47