import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int W = Integer.parseInt(st.nextToken());

        int[] a_w = new int[N];
        int[] a_v = new int[N]
            
        for (int i=0; i<N; i++) {
            st = new StringTokenizer(br.readLine());
            int w = Integer.parseInt(st.nextToken());
            int v = Integer.parseInt(st.nextToken());
            a_w[i] = w;
            a_v[i] = v;  
        }

        int[] dp = new int[101];
        dp[0] = 0; 

        for (int i=0; i<101; i++) {
            for (int j=0; j<N; j++) {
                if()
                dp[a_w[j] + a_w[i]] = Math.max(dp[i]+v, dp[a_w[i]]);
            }
            dp[a_w[i]] = Math.max(dp[i]+v, dp[a_w[i]]);
            
        }

        
        

    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: