普通的01背包问题

#include <iostream>
using namespace std;

const int N = 10010;

int v[N], w[N];
int f[N];


int main(){
    int n, m;
    cin>>n>>m;
    
    for(int i = 1; i <= n; i++) cin>>v[i]>>w[i];
    
    for(int i = 1; i <= n; i++)
        for(int j = m; j >= 0; j--)
            if(j >= w[i]) f[j] = max(f[j], f[j - w[i]] + v[i]);
        
    cout<<f[m];
    return 0;
}