Help me write a template for 01 backpack

Okay, the template for the 01 backpack is as follows:

#include<bits/stdc++.h>
using namespace std;

const int N = 1010;

int n, m;
int w[N], v[N]; // w[i]表示第i件物品的重量,v[i]表示第i件物品的价值
int f[N]; // f[i]表示前i件物品放入容量为m的背包中所能获得的最大价值

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
    for(int i = 1

Guess you like

Origin blog.csdn.net/weixin_35749796/article/details/129491189