From 28a5367d687fc1bff4da61dfce36d9e6801c268c Mon Sep 17 00:00:00 2001 From: oncsr Date: Mon, 28 Apr 2025 15:03:10 +0900 Subject: [PATCH 1/6] =?UTF-8?q?Create=20[BOJ-3020]=20=EA=B0=9C=EB=98=A5?= =?UTF-8?q?=EB=B2=8C=EB=A0=88.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\353\230\245\353\262\214\353\240\210.md" | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-3020] \352\260\234\353\230\245\353\262\214\353\240\210.md" diff --git "a/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-3020] \352\260\234\353\230\245\353\262\214\353\240\210.md" "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-3020] \352\260\234\353\230\245\353\262\214\353\240\210.md" new file mode 100644 index 00000000..79237efc --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-3020] \352\260\234\353\230\245\353\262\214\353\240\210.md" @@ -0,0 +1,88 @@ +```java + +import java.util.*; +import java.io.*; + +public 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[] S; + static int N, H; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + H = nextInt(); + S = new int[H+1]; + + } + + static void solve() throws Exception { + + PriorityQueue low = new PriorityQueue<>((a,b) -> Integer.compare(a, b)); + PriorityQueue high = new PriorityQueue<>((a,b) -> Integer.compare(b, a)); + for(int i=0;i0;i--) { + while(!high.isEmpty() && high.peek() == i) { + high.poll(); + cnt--; + } + S[i] += cnt; + } + + int min = Integer.MAX_VALUE; + cnt = 0; + for(int i=1;i<=H;i++) { + if(S[i] < min) { + min = S[i]; + cnt = 1; + } + else if(min == S[i]) cnt++; + } + bw.write(min + " " + cnt); + + } + +} + +``` From 2d5890697ee1b0066464a2d675e806a953add40c Mon Sep 17 00:00:00 2001 From: oncsr Date: Mon, 28 Apr 2025 15:28:23 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[BOJ-1911]=20=ED=9D=99=EA=B8=B8=20=EB=B3=B4?= =?UTF-8?q?=EC=88=98=ED=95=98=EA=B8=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...64\354\210\230\355\225\230\352\270\260.md" | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-1911] \355\235\231\352\270\270 \353\263\264\354\210\230\355\225\230\352\270\260.md" diff --git "a/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-1911] \355\235\231\352\270\270 \353\263\264\354\210\230\355\225\230\352\270\260.md" "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-1911] \355\235\231\352\270\270 \353\263\264\354\210\230\355\225\230\352\270\260.md" new file mode 100644 index 00000000..8eada021 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-1911] \355\235\231\352\270\270 \353\263\264\354\210\230\355\225\230\352\270\260.md" @@ -0,0 +1,64 @@ +```java + +import java.util.*; +import java.io.*; + +public 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, L; + static int[][] A; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + L = nextInt(); + A = new int[N][2]; + for(int i=0;i a[0]-b[0]); + int ans = 0, next = -1; + for(int i=0;i= e) continue; + next = Math.max(s, next); + int temp = (e-next-1)/L + 1; + ans += temp; + next += temp*L; + } + bw.write(ans + "\n"); + + } + +} + +``` From de33afcba622e0fdafdc820bc7d284989635f27b Mon Sep 17 00:00:00 2001 From: oncsr Date: Mon, 28 Apr 2025 15:47:59 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[BOJ-1800]=20=EC=9D=B8=ED=84=B0=EB=84=B7=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\353\204\267 \354\204\244\354\271\230.md" | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-1800] \354\235\270\355\204\260\353\204\267 \354\204\244\354\271\230.md" diff --git "a/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-1800] \354\235\270\355\204\260\353\204\267 \354\204\244\354\271\230.md" "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-1800] \354\235\270\355\204\260\353\204\267 \354\204\244\354\271\230.md" new file mode 100644 index 00000000..f84bc98c --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-1800] \354\235\270\355\204\260\353\204\267 \354\204\244\354\271\230.md" @@ -0,0 +1,91 @@ +```java +import java.util.*; +import java.io.*; + +public 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 final int INF = (int)1e9 + 7; + + static int N, P, K; + static List[] V; + static int[][] D; + static PriorityQueue Q; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + P = nextInt(); + K = nextInt(); + V = new List[N+1]; + for(int i=1;i<=N;i++) V[i] = new ArrayList<>(); + for(int i=0;i((a,b) -> a[0]-b[0]); + + } + + static void solve() throws Exception { + + D[N][0] = 0; + Q.offer(new int[] {0,N,0}); + int ans = INF; + while(!Q.isEmpty()) { + int[] now = Q.poll(); + int d = now[0], n = now[1], k = now[2]; + if(d > D[n][k]) continue; + if(n == 1) { + ans = Math.min(ans, d); + break; + } + for(int[] e:V[n]) { + int i = e[0], c = Math.max(d, e[1]); + // 안 쓰는 경우 + if(D[i][k] > c) { + D[i][k] = c; + Q.offer(new int[] {c,i,k}); + } + // 쓰는 경우 + if(k d) { + D[i][k+1] = d; + Q.offer(new int[] {d,i,k+1}); + } + } + } + bw.write((ans == INF ? -1 : ans) + "\n"); + + } + +} +``` From c613f92e70a8a62d7ccf8907ce902409a46b71e5 Mon Sep 17 00:00:00 2001 From: oncsr Date: Mon, 28 Apr 2025 16:37:54 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[BOJ-16681]=20=EB=93=B1=EC=82=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[BOJ-16681] \353\223\261\354\202\260.md" | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-16681] \353\223\261\354\202\260.md" diff --git "a/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-16681] \353\223\261\354\202\260.md" "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-16681] \353\223\261\354\202\260.md" new file mode 100644 index 00000000..93161cc4 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-16681] \353\223\261\354\202\260.md" @@ -0,0 +1,98 @@ +```java + +import java.util.*; +import java.io.*; + +public 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 final long INF = (long)1e18 + 7; + + static int N, M, D, E; + static List[] V; + static int[] H; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + D = nextInt(); + E = nextInt(); + + H = new int[N+1]; + for(int i=1;i<=N;i++) H[i] = nextInt(); + + V = new List[N+1]; + for(int i=1;i<=N;i++) V[i] = new ArrayList<>(); + for(int i=0;i Q = new PriorityQueue<>((a,b) -> Long.compare(a[0], b[0])); + Q.offer(new long[] {0,start}); + while(!Q.isEmpty()) { + long[] now = Q.poll(); + long d = now[0]; + int n = (int)now[1]; + if(d > X[n]) continue; + for(int[] e:V[n]) { + int i = e[0], c = e[1]; + if(X[i] > d+c && H[n] < H[i]) { + X[i] = d+c; + Q.offer(new long[] {X[i],i}); + } + } + } + return X; + } + +} + +``` From 94e3e3d27dcd0beebf6eaa85392b313e404ae9db Mon Sep 17 00:00:00 2001 From: oncsr Date: Mon, 28 Apr 2025 16:47:16 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[BOJ-23743]=20=EB=B0=A9=ED=83=88=EC=B6=9C.m?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...] \353\260\251\355\203\210\354\266\234.md" | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-23743] \353\260\251\355\203\210\354\266\234.md" diff --git "a/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-23743] \353\260\251\355\203\210\354\266\234.md" "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-23743] \353\260\251\355\203\210\354\266\234.md" new file mode 100644 index 00000000..01b3423f --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-23743] \353\260\251\355\203\210\354\266\234.md" @@ -0,0 +1,69 @@ +```java + +import java.util.*; +import java.io.*; + +public 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, M; + static List E; + static int[] r; + + static int f(int x) {return x==r[x] ? x : (r[x]=f(r[x]));} + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + r = new int[N+1]; + for(int i=0;i<=N;i++) r[i] = i; + E = new ArrayList<>(); + while(M-->0) E.add(new int[] {nextInt(), nextInt(), nextInt()}); + for(int i=1;i<=N;i++) E.add(new int[] {0, i, nextInt()}); + + } + + static void solve() throws Exception { + + Collections.sort(E, (a,b) -> a[2]-b[2]); + int ans = 0; + for(int[] e:E) { + int a = e[0], b = e[1], c = e[2]; + int x = f(a), y = f(b); + if(x==y) continue; + r[x] = y; + ans += c; + } + bw.write(ans + "\n"); + + } + +} + +``` From 307cf9aef0b03b52d2c753ae34a907c51c808c34 Mon Sep 17 00:00:00 2001 From: oncsr Date: Mon, 28 Apr 2025 17:34:52 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[BOJ-18119]=20=EB=8B=A8=EC=96=B4=20?= =?UTF-8?q?=EC=95=94=EA=B8=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\226\264 \354\225\224\352\270\260.md" | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-18119] \353\213\250\354\226\264 \354\225\224\352\270\260.md" diff --git "a/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-18119] \353\213\250\354\226\264 \354\225\224\352\270\260.md" "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-18119] \353\213\250\354\226\264 \354\225\224\352\270\260.md" new file mode 100644 index 00000000..aeca95ba --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_15\354\243\274\354\260\250/[BOJ-18119] \353\213\250\354\226\264 \354\225\224\352\270\260.md" @@ -0,0 +1,75 @@ +```java +import java.util.*; +import java.io.*; + +public 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, M; + static int[] A, O; + static int[] T; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + A = new int[N]; + T = new int[135]; + int c = 0; + for(char i='a';i<='z';i++) { + if(i=='a' || i=='e' || i=='i' || i=='o' || i=='u') T[i] = -1; + else T[i] = c++; + } + + for(int i=0;i