背包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 Erusel @ 2019-10-02 15:12:22

Orz


by 北极星欧拉56 @ 2019-10-02 15:12:37

AC了欧


by x义x @ 2019-10-02 15:12:44

Orz


by 斗神_君莫笑 @ 2019-10-02 15:13:08

Orz


by AquaRio @ 2019-10-02 15:13:43

https://www.luogu.org/discuss/show/148950


by x义x @ 2019-10-02 15:13:55

500+AC还发这种帖子?机惨?


by 冷梦233 @ 2019-10-02 15:18:18

这是被机惨了吧。。。发无意义讨论。。。


by AquaRio @ 2019-10-02 15:18:36

@x义x 我也很好奇这样一个巨佬为什么刷这种题


by vivarock @ 2019-10-04 13:45:16

太强了


by vivarock @ 2019-10-04 13:45:29

orz


| 下一页