From b1ebfe04a68a7ce0655fd124678a2f4947a74db5 Mon Sep 17 00:00:00 2001 From: oncsr Date: Sun, 22 Jun 2025 16:44:20 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[BOJ-24337]=20=EA=B0=80=ED=9D=AC=EC=99=80?= =?UTF-8?q?=20=ED=83=91.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\355\235\254\354\231\200 \355\203\221.md" | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-24337] \352\260\200\355\235\254\354\231\200 \355\203\221.md" diff --git "a/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-24337] \352\260\200\355\235\254\354\231\200 \355\203\221.md" "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-24337] \352\260\200\355\235\254\354\231\200 \355\203\221.md" new file mode 100644 index 0000000..4305cd8 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-24337] \352\260\200\355\235\254\354\231\200 \355\203\221.md" @@ -0,0 +1,113 @@ +```java +import java.math.BigInteger; +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static int N, A, B; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + public static void init() throws Exception { + + N = io.nextInt(); + A = io.nextInt(); + B = io.nextInt(); + + } + + static void solve() throws Exception { + + if(A + B > N+1) { + io.write("-1\n"); + return; + } + int[] ans = new int[N]; + if(A == 1) { + ans[0] = B; + int temp = 1; + for(int i=N-1,k=1;k++mid;i--) ans[i] = temp++; + temp = 1; + for(int i=mid-A+1;i Date: Sun, 22 Jun 2025 17:39:15 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[BOJ-1033]=20=EC=B9=B5=ED=85=8C=EC=9D=BC.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...] \354\271\265\355\205\214\354\235\274.md" | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-1033] \354\271\265\355\205\214\354\235\274.md" diff --git "a/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-1033] \354\271\265\355\205\214\354\235\274.md" "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-1033] \354\271\265\355\205\214\354\235\274.md" new file mode 100644 index 0000000..4b78fe4 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-1033] \354\271\265\355\205\214\354\235\274.md" @@ -0,0 +1,139 @@ +```java +import java.math.BigInteger; +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static int N; + static long[] A; + static List[] V; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + public static void init() throws Exception { + + N = io.nextInt(); + V = new List[N]; + for(int i=0;i(); + for(int i=1;i Date: Sun, 22 Jun 2025 18:17:39 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[BOJ-3114]=20=EC=82=AC=EA=B3=BC=EC=99=80=20?= =?UTF-8?q?=EB=B0=94=EB=82=98=EB=82=98.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \353\260\224\353\202\230\353\202\230.md" | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-3114] \354\202\254\352\263\274\354\231\200 \353\260\224\353\202\230\353\202\230.md" diff --git "a/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-3114] \354\202\254\352\263\274\354\231\200 \353\260\224\353\202\230\353\202\230.md" "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-3114] \354\202\254\352\263\274\354\231\200 \353\260\224\353\202\230\353\202\230.md" new file mode 100644 index 0000000..2ea8cc9 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-3114] \354\202\254\352\263\274\354\231\200 \353\260\224\353\202\230\353\202\230.md" @@ -0,0 +1,104 @@ +```java +import java.math.BigInteger; +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static int R, C; + static int[][] A, B; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + public static void init() throws Exception { + + R = io.nextInt(); + C = io.nextInt(); + A = new int[R+1][C+1]; + B = new int[R+1][C+1]; + for(int i=1;i<=R;i++) for(int j=1;j<=C;j++) { + String tk = io.nextToken(); + char t = tk.charAt(0); + int a = Integer.parseInt(tk.substring(1)); + if(t == 'A') A[i][j] = a; + else B[i][j] = a; + A[i][j] += A[i][j-1]; + B[i][j] += B[i-1][j]; + } + + } + + static void solve() throws Exception { + + int[][] dp = new int[R+1][C+1]; + for(int i=2;i<=R;i++) for(int j=2;j<=C;j++) { + int r1 = dp[i-1][j] + A[i][j-1]; + int r2 = dp[i][j-1] + B[i-1][j]; + int r3 = dp[i-1][j-1] + A[i][j-1] + B[i-1][j]; + dp[i][j] = Math.max(r1, Math.max(r2, r3)); + } + + io.write(dp[R][C] + "\n"); + + } + +} +``` From c9aa55ddee2deb1d3d8f0be83e1a9f8190097ec2 Mon Sep 17 00:00:00 2001 From: oncsr Date: Sun, 22 Jun 2025 18:58:45 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[BOJ-22866]=20=ED=83=91=20=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... \355\203\221 \353\263\264\352\270\260.md" | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-22866] \355\203\221 \353\263\264\352\270\260.md" diff --git "a/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-22866] \355\203\221 \353\263\264\352\270\260.md" "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-22866] \355\203\221 \353\263\264\352\270\260.md" new file mode 100644 index 0000000..733023e --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-22866] \355\203\221 \353\263\264\352\270\260.md" @@ -0,0 +1,143 @@ +```java +import java.math.BigInteger; +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static int N; + static List A; + + static List[] V; + static int[] C, deg, ans, dist; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + public static void init() throws Exception { + + N = io.nextInt(); + A = new ArrayList<>(); + for(int i=0;i list) { + + deg = new int[N]; + V = new List[N]; + for(int i=0;i(); + + int n = list.size(); + Stack stack = new Stack<>(); + for(int i=0;i stack.peek()[0]) { + int index = stack.pop()[1]; + V[x].add(index); + deg[index]++; + } + stack.push(new int[]{h, x}); + } + + } + + static void dfs(int n, int p, int d) { + C[n] += d; + if(p != -1) { + if(ans[n] == -1) { + ans[n] = p+1; + dist[n] = Math.abs(p-n); + } + else { + if(dist[n] >= Math.abs(p-n)) { + ans[n] = p+1; + dist[n] = Math.abs(p-n); + } + } + } + + for(int i:V[n]) dfs(i,n,d+1); + } + +} +```