From af3993605097c3d1a0c00ec926adefd489761343 Mon Sep 17 00:00:00 2001 From: Gyungwon Na Date: Sun, 22 Feb 2026 09:00:30 +0900 Subject: [PATCH 1/3] =?UTF-8?q?BOJ[1446]=20=EC=A7=80=EB=A6=84=EA=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nkw601/Main.java" | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 "BOJ/[1446] \354\247\200\353\246\204\352\270\270/nkw601/Main.java" diff --git "a/BOJ/[1446] \354\247\200\353\246\204\352\270\270/nkw601/Main.java" "b/BOJ/[1446] \354\247\200\353\246\204\352\270\270/nkw601/Main.java" new file mode 100644 index 0000000..ce7e50e --- /dev/null +++ "b/BOJ/[1446] \354\247\200\353\246\204\352\270\270/nkw601/Main.java" @@ -0,0 +1,80 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.PriorityQueue; +import java.util.StringTokenizer; + +public class Main { + private static int N, D; + private static int[] dist; + private static ArrayList[] arrList; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); // 지름길 개수 + D = Integer.parseInt(st.nextToken()); // 도착 거리 + + dist = new int[D + 1]; + arrList = new ArrayList[D + 1]; + + for (int i = 0; i <= D; i++) { + arrList[i] = new ArrayList<>(); + } + + Arrays.fill(dist, Integer.MAX_VALUE); + + // 원래 도로 추가 + for (int i = 0; i < D; i++) { + arrList[i].add(new int[] { i + 1, 1 }); + } + + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + int from = Integer.parseInt(st.nextToken()); + int to = Integer.parseInt(st.nextToken()); + int cost = Integer.parseInt(st.nextToken()); + + // 볼 가치 확인 + if (to > D) + continue; + if (cost >= to - from) + continue; + + arrList[from].add(new int[] { to, cost }); + } + + dijkstra(arrList, dist); + + System.out.println(dist[D]); + } + + private static void dijkstra(ArrayList[] adjList, int[] dist) { + PriorityQueue pq = new PriorityQueue<>((o1, o2) -> Integer.compare(o1[1], o2[1])); + + dist[0] = 0; + pq.offer(new int[] { 0, 0 }); + + while (!pq.isEmpty()) { + int[] cur = pq.poll(); + int curV = cur[0]; + int curD = cur[1]; + + if (curD > dist[curV]) + continue; + + for (int[] edge : adjList[curV]) { + int next = edge[0]; + int nextDist = curD + edge[1]; + + if (nextDist < dist[next]) { + dist[next] = nextDist; + pq.offer(new int[] { next, nextDist }); + } + } + } + } +} \ No newline at end of file From e07ccd8d2e2b8f2050395cbf26bc46e0554b446d Mon Sep 17 00:00:00 2001 From: Gyungwon Na Date: Sun, 22 Feb 2026 09:01:16 +0900 Subject: [PATCH 2/3] =?UTF-8?q?BOJ[20922]=20=EA=B2=B9=EC=B9=98=EB=8A=94=20?= =?UTF-8?q?=EA=B1=B4=20=EC=8B=AB=EC=96=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nkw601/Main.java" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "BOJ/[20922] \352\262\271\354\271\230\353\212\224 \352\261\264 \354\213\253\354\226\264/nkw601/Main.java" diff --git "a/BOJ/[20922] \352\262\271\354\271\230\353\212\224 \352\261\264 \354\213\253\354\226\264/nkw601/Main.java" "b/BOJ/[20922] \352\262\271\354\271\230\353\212\224 \352\261\264 \354\213\253\354\226\264/nkw601/Main.java" new file mode 100644 index 0000000..1589cd1 --- /dev/null +++ "b/BOJ/[20922] \352\262\271\354\271\230\353\212\224 \352\261\264 \354\213\253\354\226\264/nkw601/Main.java" @@ -0,0 +1,40 @@ +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int K = Integer.parseInt(st.nextToken()); + + int[] arr = new int[N]; + // 등장 횟수 + int[] count = new int[100001]; + + st = new StringTokenizer(br.readLine()); + for (int i = 0; i < N; i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + + int left = 0; + int ans = 0; + + for (int right = 0; right < N; right++) { + // right 한 칸 앞 -> 숫자 등장 + count[arr[right]]++; + // K번보다 많이 나오면 + while (count[arr[right]] > K) { + // 최장연속수열 불가능 + count[arr[left]]--; + left++; + } + + // 길이 갱신하기 + ans = Math.max(ans, right - left + 1); + } + + System.out.println(ans); + } +} \ No newline at end of file From 72382b82f74c09c9fbdab8c452e8251b65c48179 Mon Sep 17 00:00:00 2001 From: Gyungwon Na Date: Sun, 22 Feb 2026 09:02:12 +0900 Subject: [PATCH 3/3] =?UTF-8?q?BOJ[1253]=20=EC=A2=8B=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nkw601/Main.java" | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 "BOJ/[1253] \354\242\213\353\213\244/nkw601/Main.java" diff --git "a/BOJ/[1253] \354\242\213\353\213\244/nkw601/Main.java" "b/BOJ/[1253] \354\242\213\353\213\244/nkw601/Main.java" new file mode 100644 index 0000000..d790200 --- /dev/null +++ "b/BOJ/[1253] \354\242\213\353\213\244/nkw601/Main.java" @@ -0,0 +1,53 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int N = Integer.parseInt(br.readLine()); + int[] numbers = new int[N]; + + StringTokenizer st = new StringTokenizer(br.readLine()); + for (int i = 0; i < N; i++) { + numbers[i] = Integer.parseInt(st.nextToken()); + } + + Arrays.sort(numbers); + + int ans = 0; + + for (int i = 0; i < N; i++) { + int target = numbers[i]; + int left = 0; + int right = N - 1; + + while (left < right) { + if (left == i) { + left++; + continue; + } + if (right == i) { + right--; + continue; + } + + int sum = numbers[left] + numbers[right]; + + if (sum == target) { + ans++; + break; + } else if (sum < target) { + left++; + } else { + right--; + } + } + } + + System.out.println(ans); + } +} \ No newline at end of file