From 35d9223ea2fdbe54637180349a99a3b86b051de6 Mon Sep 17 00:00:00 2001 From: oncsr Date: Thu, 20 Mar 2025 10:29:06 +0900 Subject: [PATCH] =?UTF-8?q?[20250320]=20BOJ=20/=20G5=20/=20=EC=A3=BC?= =?UTF-8?q?=EC=8B=9D=20/=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20 BOJ G5 \354\243\274\354\213\235.md" | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 "khj20006/202503/20 BOJ G5 \354\243\274\354\213\235.md" diff --git "a/khj20006/202503/20 BOJ G5 \354\243\274\354\213\235.md" "b/khj20006/202503/20 BOJ G5 \354\243\274\354\213\235.md" new file mode 100644 index 00000000..b6ef9bc9 --- /dev/null +++ "b/khj20006/202503/20 BOJ G5 \354\243\274\354\213\235.md" @@ -0,0 +1,82 @@ +```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 { + if(!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, M, K; + static long[] p; + static long ans; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + K = nextInt()+1; + p = new long[N]; + for(int i=0;i 0) { + bck(curMoney, borrow, count, day+1); + long benefit = count * p[day]; + curMoney += benefit; + ans = Math.max(ans, curMoney); + curMoney -= borrow; + if(curMoney < 0) return; + borrow = 0; + count = 0; + } + bck(curMoney, borrow, count, day+1); + borrow = curMoney * (K-1); + curMoney *= K; + count = curMoney / p[day]; + curMoney -= count * p[day]; + if(count > 0) bck(curMoney, borrow, count, day+1); + + } + +} + +```