为啥子本地过了但是在线就是不过啊QAQ

P1048 [NOIP2005 普及组] 采药

@[柚子皮](/space/show?uid=112889) 所以我这个属于哪一种啊,我这在mac本地过的。
by Kater_kcl @ 2019-07-13 21:01:43


@[Kater_kcl](/space/show?uid=206553) 可以换个~~号~~/机子测测看orz
by All_Might @ 2019-07-13 21:02:22


@[杨蒟蒻](/space/show?uid=65880) 莫得机器QAQ,而且我在线ide给出的答案也不对。
by Kater_kcl @ 2019-07-13 21:03:17


希望更丰富的展现?[使用Markdown](https://www.luogu.org/wiki/show?name=%E5%B8%AE%E5%8A%A9%EF%BC%9Amarkdown) ```cpp #include<iostream> #include<stdio.h> using namespace std; int w[105],val[105]; int dp[105][1005]; int main() { int t,m,res=-1; scanf("%d%d",&t,&m); for(int i=1; i<=m; i++) scanf("%d%d",&w[i],&val[i]); for(int i=1; i<=m; i++) for(int j=t; j>=0; j--) if(j>=w[i]) dp[i][j]=max(dp[i-1][j-w[i]]+val[i],dp[i-1][j]); else dp[i][j]=dp[i-1][j]; printf("%d",dp[m][t]); return 0; } ```
by lin_god @ 2019-07-13 21:03:40


```cpp #include<bits/stdc++.h> using namespace std; const int maxm=1000,maxt=100; int t,m; int w[maxt],c[maxm]; int f[maxm]; int main() { cin>>t>>m; for (int i=1; i<=m;i++) cin>>w[i]>>c[i]; for (int i=1; i<=m;i++) for (int v=t;v>=w[i];v--) if(f[v-w[i]]+c[i]>f[v]) f[v]=f[v-w[i]]+c[i]; cout<<f[t]; return 0; } ``` 您可以借鉴下我的程序
by All_Might @ 2019-07-13 21:05:07


@[杨蒟蒻](/space/show?uid=65880) 感谢QAQ
by Kater_kcl @ 2019-07-13 21:05:50


@[Kater_kcl](/space/show?uid=206553) 你私信一下 lin_toto
by Boring__Zheng @ 2019-07-14 08:07:58


上一页 |