diff --git "a/wonjunYou/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/BOJ_\355\230\270\355\205\224.java" "b/wonjunYou/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/BOJ_\355\230\270\355\205\224.java" new file mode 100644 index 00000000..62589270 --- /dev/null +++ "b/wonjunYou/\353\213\244\354\235\264\353\202\230\353\257\271 \355\224\204\353\241\234\352\267\270\353\236\230\353\260\215/BOJ_\355\230\270\355\205\224.java" @@ -0,0 +1,37 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public 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 c = Integer.parseInt(st.nextToken()); + int n = Integer.parseInt(st.nextToken()); + + int[] dp = new int[c + 100]; + Arrays.fill(dp, Integer.MAX_VALUE); + dp[0] = 0; + + for (int i = 0; i < n; i++) { + st = new StringTokenizer(br.readLine()); + int cost = Integer.parseInt(st.nextToken()); + int customer = Integer.parseInt(st.nextToken()); + + for (int j = customer; j < c + 100; j++) { + if (dp[j - customer] != Integer.MAX_VALUE) + dp[j] = Math.min(dp[j], cost + dp[j - customer]); + } + } + + int answer = Integer.MAX_VALUE; + for (int i = c; i < c + 100; i++) { + answer = Math.min(answer, dp[i]); + } + System.out.println(answer); + } +}