c_s_x @ 2023-07-20 10:53:05
本地对了,在洛谷错了!!!#5 #6!
by _Fancy_ @ 2023-07-20 11:07:19
@c_s_x where is your code?
by c_s_x @ 2023-07-20 11:10:55
#include <algorithm>
using namespace std;
int n,m,v[100],f[32005],w[100],ver,zhu[105],tot,toy[105],zhi[105][3];
int main() {
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++) {
scanf("%d%d%d",&v[i],&w[i],&ver);w[i]*=v[i];
if(!ver) zhu[++tot]=i;
else toy[ver]++; zhi[ver][toy[ver]]=i;
}
int x,t1,t2;
for(int i=1;i<=tot;i++) {
x=zhu[i];
for(int j=n;j>=v[x];j--){
f[j]=max(f[j],f[j-v[x]]+w[x]);
if(toy[x]>=1) {
t1=zhi[x][1];
if(v[x]+v[t1]<=j)
f[j]=max(f[j],f[j-v[x]-v[t1]]+w[x]+w[t1]);
}
if(toy[x]==2) {
t2=zhi[x][2];
if(v[x]+v[t2]<=j)
f[j]=max(f[j],f[j-v[x]-v[t1]]+w[x]+w[t1]);
if(v[x]+v[t2]+v[t1]<=j)
f[j]=max(f[j],f[j-v[x]-v[t1]-v[t2]]+w[x]+w[t1]+w[t2]);
}
}
}
printf("%d",f[n]);
return 0;
} ```
by karanoli @ 2023-07-20 11:27:29
@c_s_x 开小了
by karanoli @ 2023-07-20 11:28:24
@karanoli 我就开大,然后万能头就过了