import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer NW = new StringTokenizer(br.readLine());
int N = Integer.parseInt(NW.nextToken());
int W = Integer.parseInt(NW.nextToken());
long INF = Long.MAX_VALUE;
long[] dp = new long[10001]; // 무게를 담는 dp
Arrays.fill(dp, INF);
int[][] wv_list = new int[N][2];
dp[0] = 0;
for (int i=0; i<N; i++) {
NW = new StringTokenizer(br.readLine());
wv_list[i][0] = Integer.parseInt(NW.nextToken());
wv_list[i][1] = Integer.parseInt(NW.nextToken());
}
for (int i=0; i<N; i++) {
int this_w = wv_list[i][0];
int this_v = wv_list[i][1];
for (int j=10000-this_v; j >=0; j--) {
if (dp[j] == INF) continue;
dp[j+this_v] = Math.min(dp[j+this_v], dp[j]+this_w);
}
}
for (int i=10000; i>=0; i--) {
// i개 value고 안에 dp[i]가 무게임
if (dp[i] <=W ) {
System.out.println(i);
break;
}
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: