大伙帮忙 看看啊, 思考了很久都不知道 那里错了

P1064 [NOIP2006 提高组] 金明的预算方案

肥婆纳妾 @ 2018-12-27 02:25:53

0分代码。。。


#if 1
#include<bits/stdc++.h>
using namespace std;
vector<int> w,v,att_w,att_v;
int dp[10000],t1,t2,t3;
inline int read() {
    int X = 0, w = 0; char ch = 0;
    while (!isdigit(ch)) { w |= ch == '-'; ch = getchar(); }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
int main()
{
    int m, n;
    m=read(),n=read();
    m/=10;
    for (int i = 1; i <= n; ++i) {
        t1=read(),t2=read(),t3=read();
        if(t3){         //主件
            att_w.push_back(t1/10);
            att_v.push_back(t2*t1/10);
        }
        else{           //附件
            w.push_back(t1/10);
            v.push_back(t2*t1/10);
        }
    }
    for (int i = 0;i <w.size(); ++i) {
        for (int j = m; j >= w[i]; --j) {
            dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
            if(j>=(w[i]+att_w[0]))
                dp[j]=max(dp[j],dp[j-w[i]-att_w[0]] +v[i]+att_v[0]);
            if(j>=(w[i]+att_w[1]))
                dp[j]=max(dp[j],dp[j-w[i]-att_w[1]]+v[i]+att_v[1]);
            if(j>=(w[i]+att_w[0]+att_w[1]))
                dp[j]=max(dp[j],dp[j-w[i]-att_w[0]-att_w[1]]+v[i]+att_v[0]+att_v[1]);
        }
    }
    cout<<dp[m];
    return 0;
}

#endif 

|