From 19d267e14c32cb0e7d5004a3af402d47dd6f4c9e Mon Sep 17 00:00:00 2001 From: junhochoi-dev Date: Wed, 8 Nov 2023 10:16:57 +0900 Subject: [PATCH 1/7] [solved] boj14226.java --- ChoiJunHo/BOJ/study29_1109/boj14226.java | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 ChoiJunHo/BOJ/study29_1109/boj14226.java diff --git a/ChoiJunHo/BOJ/study29_1109/boj14226.java b/ChoiJunHo/BOJ/study29_1109/boj14226.java new file mode 100644 index 00000000..d6a9490c --- /dev/null +++ b/ChoiJunHo/BOJ/study29_1109/boj14226.java @@ -0,0 +1,34 @@ +import java.io.*; +import java.util.*; + +public class Main{ + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + static StringTokenizer st; + + public static void main(String[] args) throws IOException { + int[] dist = new int[1000 + 1]; + Arrays.fill(dist, Integer.MAX_VALUE); + dist[1] = 0; + + Queue queue = new ArrayDeque(); + queue.add(1); + while(!queue.isEmpty()){ + int curr = queue.poll(); + + for(int mul = 2; mul * curr <= 1000; mul++){ + if(dist[curr * mul] <= dist[curr] + mul) continue; + dist[curr * mul] = dist[curr] + mul; + queue.add(curr * mul); + } + + for(int sub = 1; sub < curr; sub++){ + if(dist[curr - sub] <= dist[curr] + sub) break; + dist[curr - sub] = dist[curr] + sub; + queue.add(curr - sub); + } + } + int S = Integer.parseInt(br.readLine()); + System.out.println(dist[S]); + } +} \ No newline at end of file From ae355f19a59222ee1331a2badb56a66c0a7d8664 Mon Sep 17 00:00:00 2001 From: junhochoi-dev Date: Wed, 8 Nov 2023 10:17:49 +0900 Subject: [PATCH 2/7] [solved] boj23829.java --- ChoiJunHo/BOJ/study29_1109/boj23829.java | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 ChoiJunHo/BOJ/study29_1109/boj23829.java diff --git a/ChoiJunHo/BOJ/study29_1109/boj23829.java b/ChoiJunHo/BOJ/study29_1109/boj23829.java new file mode 100644 index 00000000..acfca0a8 --- /dev/null +++ b/ChoiJunHo/BOJ/study29_1109/boj23829.java @@ -0,0 +1,46 @@ +import java.io.*; +import java.util.*; + +public class Main{ + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + static StringTokenizer st; + + public static void main(String[] args) throws IOException { + st = new StringTokenizer(br.readLine()); + int N = Integer.parseInt(st.nextToken()); + int Q = Integer.parseInt(st.nextToken()); + + long[] distance = new long[N]; + long[] distanceSum = new long[N]; + st = new StringTokenizer(br.readLine()); + for(int i = 0; i < N; i++){ + distance[i] = Long.parseLong(st.nextToken()); + } + Arrays.sort(distance); + for(int i = 0; i < N; i++){ + distanceSum[i] = distance[i] + (i > 0 ? distanceSum[i - 1] : 0); + } + for(int i = 0; i < Q; i++){ + int low = 0; + int high = N - 1; + int x = Integer.parseInt(br.readLine()); + + int idx = N - 1; + while(low <= high){ + int mid = (low + high) / 2; + if(distance[mid] <= x){ + low = mid + 1; + idx = mid; + } else { + high = mid - 1; + } + } + long answer = 0; + answer += Math.abs(distanceSum[N - 1] - distanceSum[idx] - (long) x * (N - idx - 1)); + answer += Math.abs((long) x * (idx + 1) - distanceSum[idx]); + sb.append(answer).append('\n'); + } + System.out.println(sb); + } +} From 62dda48f6d21e6eef47d72045acde7336ad8b0ab Mon Sep 17 00:00:00 2001 From: junhochoi-dev Date: Mon, 27 Nov 2023 11:10:43 +0900 Subject: [PATCH 3/7] [solved] boj17092.java --- ChoiJunHo/BOJ/study29_1109/boj17092.java | 60 ++++++++++++++++++++++++ readme.md | 12 +++++ 2 files changed, 72 insertions(+) create mode 100644 ChoiJunHo/BOJ/study29_1109/boj17092.java diff --git a/ChoiJunHo/BOJ/study29_1109/boj17092.java b/ChoiJunHo/BOJ/study29_1109/boj17092.java new file mode 100644 index 00000000..118449ab --- /dev/null +++ b/ChoiJunHo/BOJ/study29_1109/boj17092.java @@ -0,0 +1,60 @@ +import java.io.*; +import java.util.*; + +public class Main{ + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + static StringTokenizer st; + + public static void main(String[] args) throws IOException { + int[][] dx = { + {0, 0, 0, 1, 1, 1, 2, 2, 2}, + {0, 0, 0, -1, -1, -1, 1, 1, 1}, + {0, 0, 0, -1, -1, -1, -2, -2, -2} + }; + int[][] dy = { + {1, 2, 0, 1, 2, 0, 1, 2, 0}, + {-1, 0, 1, -1, 0, 1, -1, 0, 1}, + {-2, -1, 0, -2, -1, 0, -2, -1, 0} + }; + st = new StringTokenizer(br.readLine()); + long H = Long.parseLong(st.nextToken()); + long W = Long.parseLong(st.nextToken()); + int N = Integer.parseInt(st.nextToken()); + + HashSet loc = new HashSet(); + for(int i = 0; i < N; i++){ + st = new StringTokenizer(br.readLine()); + long x = Long.parseLong(st.nextToken()) - 1; + long y = Long.parseLong(st.nextToken()) - 1; + loc.add(x * W + y); + } + + long[] cnt = new long[10]; + for(long curr : loc){ + long x = curr / W; + long y = curr % W; + + for(int i = 0; i < 3; i++){ + for(int j = 0; j < 3; j++){ + int count = 0; + boolean able = true; + for(int k = 0; k < 9; k++){ + long tx = x + dx[i][k]; + long ty = y + dy[j][k]; + if(tx < 0 || ty < 0 || tx >= H || ty >= W){ + able = false; + break; + } + if(loc.contains(tx * W + ty)) count++; + } + if(able) cnt[count]++; + } + } + } + cnt[0] = (H - 2) * (W - 2); + for(int i = 1; i < 10; i++) cnt[i] /= i; + for(int i = 1; i < 10; i++) cnt[0] -= cnt[i]; + for(int i = 0; i < 10; i++) System.out.println(cnt[i]); + } +} diff --git a/readme.md b/readme.md index b41371ef..f850f4e2 100644 --- a/readme.md +++ b/readme.md @@ -156,3 +156,15 @@ PR Comment : ### 건의사항 `Discussions` 나 MM채널, 개인 MM을 이용한다. + + +--- + +### 결과 + + +| 8월 | 9월 | 10월 | +| -------- | -------- | -------- | +| | | | + + From 784ef61cf9ec5d8411db2e76eb56a380a6e1c73c Mon Sep 17 00:00:00 2001 From: junhochoi-dev Date: Mon, 27 Nov 2023 11:13:54 +0900 Subject: [PATCH 4/7] [solved] boj25195.java --- ChoiJunHo/BOJ/study30_0000/boj25195.java | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 ChoiJunHo/BOJ/study30_0000/boj25195.java diff --git a/ChoiJunHo/BOJ/study30_0000/boj25195.java b/ChoiJunHo/BOJ/study30_0000/boj25195.java new file mode 100644 index 00000000..5d59e813 --- /dev/null +++ b/ChoiJunHo/BOJ/study30_0000/boj25195.java @@ -0,0 +1,48 @@ +import java.io.*; +import java.util.*; + +public class Main{ + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + static StringTokenizer st; + + public static void main(String[] args) throws IOException { + st = new StringTokenizer(br.readLine()); + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + HashMap> edge = new HashMap>(); + for(int i = 0; i < M; i++){ + st = new StringTokenizer(br.readLine()); + int s = Integer.parseInt(st.nextToken()); + int e = Integer.parseInt(st.nextToken()); + if(!edge.containsKey(s)) edge.put(s, new ArrayList()); + edge.get(s).add(e); + } + + int S = Integer.parseInt(br.readLine()); + st = new StringTokenizer(br.readLine()); + HashSet fanclub = new HashSet(); + for(int i = 0; i < S; i++) fanclub.add(Integer.parseInt(st.nextToken())); + + + Queue queue = new ArrayDeque<>(); + if(!fanclub.contains(1)) queue.add(1); + + boolean answer = false; + while(!queue.isEmpty()){ + int curr = queue.poll(); + + if(edge.containsKey(curr)){ + for(int next : edge.get(curr)){ + if(fanclub.contains(next)) continue; + queue.add(next); + } + } else { + answer = true; + } + } + + System.out.println(answer ? "yes" : "Yes"); + } +} From 2f01448aaa57d03c3b4f415bee2563faf3e3aec6 Mon Sep 17 00:00:00 2001 From: junhochoi-dev Date: Mon, 27 Nov 2023 11:16:43 +0900 Subject: [PATCH 5/7] [solved] boj28449.java --- ChoiJunHo/BOJ/study30_0000/boj28449.java | 64 ++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 ChoiJunHo/BOJ/study30_0000/boj28449.java diff --git a/ChoiJunHo/BOJ/study30_0000/boj28449.java b/ChoiJunHo/BOJ/study30_0000/boj28449.java new file mode 100644 index 00000000..d9daf42c --- /dev/null +++ b/ChoiJunHo/BOJ/study30_0000/boj28449.java @@ -0,0 +1,64 @@ +import java.io.*; +import java.util.*; + +public class Main{ + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + static StringTokenizer st; + + public static void main(String[] args) throws IOException { + st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + int[] a = new int[N]; + int[] b = new int[M]; + + st = new StringTokenizer(br.readLine()); + for(int i = 0; i < N; i++) a[i] = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + for(int i = 0; i < M; i++) b[i] = Integer.parseInt(st.nextToken()); + + Arrays.sort(a); + Arrays.sort(b); + + long win = 0, draw = 0, lose = 0; + + for(int i = 0; i < N; i++){ + int curr = a[i]; + + int low = 0; + int high = M - 1; + + int upperbound = M; + while(low <= high){ + int mid = (low + high) / 2; + if(curr < b[mid]){ + high = mid - 1; + upperbound = mid; + } else { + low = mid + 1; + } + } + + low = 0; + high = M - 1; + int lowerbound = -1; + while(low <= high){ + int mid = (low + high) / 2; + if(curr <= b[mid]){ + high = mid - 1; + } else { + low = mid + 1; + lowerbound = mid; + } + } + win += lowerbound + 1; + draw += upperbound - lowerbound - 1; + lose += M - upperbound; + } + System.out.print(win + " " + lose + " " + draw); + } +} From ba29e3f96997c4f73921fb2161663be5089b3b11 Mon Sep 17 00:00:00 2001 From: junhochoi-dev Date: Mon, 27 Nov 2023 11:18:02 +0900 Subject: [PATCH 6/7] [solved] boj27896.java --- ChoiJunHo/BOJ/study30_0000/boj27896.java | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 ChoiJunHo/BOJ/study30_0000/boj27896.java diff --git a/ChoiJunHo/BOJ/study30_0000/boj27896.java b/ChoiJunHo/BOJ/study30_0000/boj27896.java new file mode 100644 index 00000000..7c3a696f --- /dev/null +++ b/ChoiJunHo/BOJ/study30_0000/boj27896.java @@ -0,0 +1,29 @@ +import java.io.*; +import java.util.*; + +public class Main{ + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + static StringTokenizer st; + + public static void main(String[] args) throws IOException { + st = new StringTokenizer(br.readLine()); + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + PriorityQueue pq = new PriorityQueue(); + st = new StringTokenizer(br.readLine()); + int satisfaction = 0; + int eggplant = 0; + for(int i = 0; i < N; i++) { + int x = Integer.parseInt(st.nextToken()); + satisfaction += x; + pq.add(-x); + while(satisfaction >= M){ + satisfaction -= -pq.poll() * 2; + eggplant++; + } + } + System.out.println(eggplant); + } +} From 175d99906480c5dadd0310cd62cc665e3d12028e Mon Sep 17 00:00:00 2001 From: junhochoi-dev Date: Mon, 27 Nov 2023 11:18:41 +0900 Subject: [PATCH 7/7] [fix] directory name change --- ChoiJunHo/BOJ/{study30_0000 => study30_1113}/boj25195.java | 0 ChoiJunHo/BOJ/{study30_0000 => study30_1113}/boj27896.java | 0 ChoiJunHo/BOJ/{study30_0000 => study30_1113}/boj28449.java | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename ChoiJunHo/BOJ/{study30_0000 => study30_1113}/boj25195.java (100%) rename ChoiJunHo/BOJ/{study30_0000 => study30_1113}/boj27896.java (100%) rename ChoiJunHo/BOJ/{study30_0000 => study30_1113}/boj28449.java (100%) diff --git a/ChoiJunHo/BOJ/study30_0000/boj25195.java b/ChoiJunHo/BOJ/study30_1113/boj25195.java similarity index 100% rename from ChoiJunHo/BOJ/study30_0000/boj25195.java rename to ChoiJunHo/BOJ/study30_1113/boj25195.java diff --git a/ChoiJunHo/BOJ/study30_0000/boj27896.java b/ChoiJunHo/BOJ/study30_1113/boj27896.java similarity index 100% rename from ChoiJunHo/BOJ/study30_0000/boj27896.java rename to ChoiJunHo/BOJ/study30_1113/boj27896.java diff --git a/ChoiJunHo/BOJ/study30_0000/boj28449.java b/ChoiJunHo/BOJ/study30_1113/boj28449.java similarity index 100% rename from ChoiJunHo/BOJ/study30_0000/boj28449.java rename to ChoiJunHo/BOJ/study30_1113/boj28449.java