背包DP做法

P1478 陶陶摘苹果(升级版)

北极星欧拉56 @ 2019-10-02 15:11:58


#include<bits/stdc++.h>
using namespace std;
struct catchapple
{
    int hi;
    int force;
};
catchapple a[10001];
int n,c,b,x,i,j;
int f[10001];
int main()
{
    cin>>n>>x>>c>>b;
    for(i=1;i<=n;i++)
        cin>>a[i].hi>>a[i].force;
    for(i=1;i<=n;i++)
        for(j=x;j>=a[i].force;j--)
            if(c+b>=a[i].hi)
                f[j]=max(f[j],f[j-a[i].force]+1);
    cout<<f[x];
    return 0;       
}

by Megumi9 @ 2019-10-04 17:20:37

Orz tql %%%%%%%%%%%%%%%%%


by MurderChara @ 2019-10-05 12:50:32

tql Orz %%%%%%


上一页 |