这道题第一问不是01背包嘛?还是我写错了?
查看原帖
这道题第一问不是01背包嘛?还是我写错了?
105820
阿尔托莉雅丶楼主2021/1/11 14:17
//---
#include <iostream>
using namespace std;
const int N = 1e5 + 5;

int n = 0;
int h[N], f[N];

int main(void)
{
    int w = 5e4;
    while(cin >> h[++n])
        ;
    
    for(int i = 1; i <= n; i++)
        for(int j = w; j >= h[i]; j--)
            f[j] = max(f[j], f[h[i]] + 1);

    cout << f[w];
    return 0;
}

对于一发炮弹 我可以选择拦截,或者不拦截

2021/1/11 14:17
加载中...