From b689657da3ee78878911a23238ee81326bcd3d2c Mon Sep 17 00:00:00 2001 From: oncsr Date: Mon, 7 Apr 2025 15:51:08 +0900 Subject: [PATCH] =?UTF-8?q?[20250407]=20BOJ=20/=20G2=20/=20=EB=B0=A9?= =?UTF-8?q?=EB=AC=B8=20=ED=8C=90=EB=A7=A4=20/=20=EA=B6=8C=ED=98=81?= =?UTF-8?q?=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1\353\254\270 \355\214\220\353\247\244.md" | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 "khj20006/202504/07 BOJ G2 \353\260\251\353\254\270 \355\214\220\353\247\244.md" diff --git "a/khj20006/202504/07 BOJ G2 \353\260\251\353\254\270 \355\214\220\353\247\244.md" "b/khj20006/202504/07 BOJ G2 \353\260\251\353\254\270 \355\214\220\353\247\244.md" new file mode 100644 index 00000000..e2bd8f77 --- /dev/null +++ "b/khj20006/202504/07 BOJ G2 \353\260\251\353\254\270 \355\214\220\353\247\244.md" @@ -0,0 +1,90 @@ +```java + +import java.util.*; +import java.io.*; + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N, X, Y; + static int[] x, y; + static int[][] max, rec; + + static final int INF = -123456; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + X = nextInt(); + Y = nextInt(); + x = new int[N]; + y = new int[N]; + for(int i=0;i0;c--) for(int j=100*(i+1);j>=x[i];j--) if(max[j-x[i]][c-1] != INF) { + if(max[j][c] < Y && max[j-x[i]][c-1] + y[i] >= Y) { + rec[j][c] = i+1; + } + max[j][c] = Math.max(max[j][c], max[j-x[i]][c-1] + y[i]); + } + } + + for(int c=1;c<=N;c++) { + boolean find = false; + int min = -INF; + for(int i=X;i<=5000;i++) if(max[i][c] >= Y) { + find = true; + min = Math.min(min, rec[i][c]); + } + if(find) { + bw.write(c + "\n" + min); + return; + } + } + bw.write("-1"); + + } + +} + +```