hhhw @ 2018-09-07 13:08:31
只有10分emmm……
#include <bits/stdc++.h>
#define ixi(i,a,b) for(int i=a;i<=b;++i)
#define dxd(i,b,a) for(int i=b;i>=a;--i)
using namespace std;
const int N = 66;
int d[32010],s[N][2],v[N],p,n,m,z,q[N],w[N];
int main(){
freopen("v1.txt","r",stdin);
cin >> n >> m;
ixi(i,1,m){
cin >> v[i] >> p >> z;
w[i] = v[i]*p; q[i]=z;
if(z) (s[z][0]?s[z][1]:s[z][0])=i;
}
ixi(i,1,m){
if(q[i]) continue;
dxd(j,n,v[i]){
d[j] = max(d[j],d[j-v[i]]+w[i]);
if(j>=v[i]+v[s[i][0]])
d[j] = max(d[j],d[j-v[i]-v[s[i][0]]]+w[i]+w[s[i][0]]);
if(j>=v[i]+v[s[i][1]])
d[j] = max(d[j],d[j-v[i]-v[s[i][1]]]+w[i]+w[s[i][1]]);
if(j>=v[i]+v[s[i][0]]+v[s[i][1]])
d[j] = max(d[j],d[j-v[i]-v[s[i][0]-v[s[i][1]]]]+w[i]+w[s[i][0]]+w[s[i][1]]);
}
}
cout << d[n] << endl;
return 0;
}
by hhhw @ 2018-09-07 13:15:31
emmm...
freopen
去掉了
by hhhw @ 2018-09-07 13:15:38
第一重循环if(q[i]) continue;
改成if(!q[i]) continue;
by hhhw @ 2018-09-07 13:16:28
还是不行……
by hhhw @ 2018-09-07 13:18:27
@uuuxxllj emmm...第二个回复改错了……
by ___I_AK_IOI @ 2018-09-09 20:57:38
兄弟我连10分都没有,不知道我的核心代码哪里写错了。