请问各位dalao为什么错了

P1048 [NOIP2005 普及组] 采药

输入格式 第一行有2个整数T和M **T(1≤T≤1000)**
by StarLbright40 @ 2019-12-01 09:27:11


数组开小了...
by _yjh @ 2019-12-01 09:28:38


@[LySHEN](/user/225439) ```cpp int dp[1005]={0},Price[1005],Mass[1005]; ```
by 十十十十 @ 2019-12-01 09:30:52


dp开1005就行,别的不需要
by StarLbright40 @ 2019-12-01 09:32:13


```cpp #include<bits/stdc++.h> using namespace std; int dp[1005]={0},Price[1005],Mass[1005]; int main(){ int Volume,M; cin>>Volume>>M; for(int i=0;i<M;i++) cin>>Mass[i]>>Price[i]; for(int i=0;i<M;i++) for(int j=Volume;j>=Mass[i];--j) dp[j]=max(dp[j],dp[j-Mass[i]]+Price[i]); cout<<dp[Volume]; return 0; } ``` 亲测AC
by _yjh @ 2019-12-01 09:33:00


您的头像有危险
by 荣巴 @ 2019-12-01 09:34:28


|