From e4e3f6492c16182aeb12093ba638801a5f352205 Mon Sep 17 00:00:00 2001 From: JAEKWANG97 Date: Mon, 27 Oct 2025 09:40:38 +0900 Subject: [PATCH 1/3] =?UTF-8?q?2872/40=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JAEKWANG97/BOJ_2872.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 JAEKWANG97/BOJ_2872.java diff --git a/JAEKWANG97/BOJ_2872.java b/JAEKWANG97/BOJ_2872.java new file mode 100644 index 0000000..b46a8ec --- /dev/null +++ b/JAEKWANG97/BOJ_2872.java @@ -0,0 +1,20 @@ +import java.util.*; + +public class BOJ_2872 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + // 우측부터 가장 큰수로 시작되는 연속된 내림차순 부분 수열을 찾으면 됨 + List list = new ArrayList<>(); + for (int i = 0; i < n; i++) { + list.add(sc.nextInt()); + } + int expected = n; + for (int i = n - 1; i >= 0; i--) { + if( list.get(i) == expected) { + expected--; + } + } + System.out.println(expected); + } +} \ No newline at end of file From 2e5354606e44872a12262d606cb52f2edf043cc2 Mon Sep 17 00:00:00 2001 From: JAEKWANG97 Date: Mon, 27 Oct 2025 09:40:49 +0900 Subject: [PATCH 2/3] =?UTF-8?q?14718/50=EB=B6=84=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JAEKWANG97/BOJ_14718.java | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 JAEKWANG97/BOJ_14718.java diff --git a/JAEKWANG97/BOJ_14718.java b/JAEKWANG97/BOJ_14718.java new file mode 100644 index 0000000..1a54f06 --- /dev/null +++ b/JAEKWANG97/BOJ_14718.java @@ -0,0 +1,45 @@ +import java.io.*; +import java.util.*; + +public class BOJ_14718 { + public static void main(String[] args) throws IOException { + 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[][] enemies = new int[N][3]; + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + enemies[i][0] = Integer.parseInt(st.nextToken()); + enemies[i][1] = Integer.parseInt(st.nextToken()); + enemies[i][2] = Integer.parseInt(st.nextToken()); + } + + int answer = Integer.MAX_VALUE; + + // 모든 가능한 능력치 조합 완전 탐색 + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + for (int k = 0; k < N; k++) { + int a = enemies[i][0]; + int b = enemies[j][1]; + int c = enemies[k][2]; + + int count = 0; + for (int e = 0; e < N; e++) { + if (a >= enemies[e][0] && b >= enemies[e][1] && c >= enemies[e][2]) { + count++; + } + } + + if (count >= K) { + answer = Math.min(answer, a + b + c); + } + } + } + } + + System.out.println(answer); + } +} From 0dd50f2998b26187d84bb54b73100a3245c6a213 Mon Sep 17 00:00:00 2001 From: JAEKWANG97 Date: Mon, 27 Oct 2025 09:41:39 +0900 Subject: [PATCH 3/3] =?UTF-8?q?16973/60=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JAEKWANG97/BOJ_16973.java | 118 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 JAEKWANG97/BOJ_16973.java diff --git a/JAEKWANG97/BOJ_16973.java b/JAEKWANG97/BOJ_16973.java new file mode 100644 index 0000000..23edba4 --- /dev/null +++ b/JAEKWANG97/BOJ_16973.java @@ -0,0 +1,118 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayDeque; +import java.util.Queue; +import java.util.StringTokenizer; + +class BOJ_16973 { + static class Location { + int r; + int c; + + public Location(int r, int c) { + this.r = r; + this.c = c; + } + + @Override + public String toString() { + return "Location [r=" + r + ", c=" + c + "]"; + } + } + + private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static StringTokenizer st; + + private static int N, M, H, W; + private static int[][] map; + private static boolean[][] visited; + private static Location start; + private static Location end; + + public static void main(String[] args) throws IOException { + init(); + bfs(); + } + + private static void init() throws IOException { + st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + map = new int[N][M]; + visited = new boolean[N][M]; + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + for (int j = 0; j < M; j++) { + map[i][j] = Integer.parseInt(st.nextToken()); + } + } + st = new StringTokenizer(br.readLine()); + H = Integer.parseInt(st.nextToken()); + W = Integer.parseInt(st.nextToken()); + start = new Location(Integer.parseInt(st.nextToken()) - 1, Integer.parseInt(st.nextToken()) - 1); + end = new Location(Integer.parseInt(st.nextToken()) - 1, Integer.parseInt(st.nextToken()) - 1); + + } + + private static void bfs() { + Queue queue = new ArrayDeque<>(); + queue.offer(start); + visited[start.r][start.c] = true; + + int[] dr = {-1, 0, 1, 0}; + int[] dc = {0, 1, 0, -1}; + int count = 0; + while (!queue.isEmpty()) { + int size = queue.size(); + for (int s = 0; s < size; s++) { + Location cur = queue.poll(); + + if (cur.r == end.r && cur.c == end.c) { + System.out.println(count); + return; + } + + for (int d = 0; d < 4; d++) { + int nr = cur.r + dr[d]; + int nc = cur.c + dc[d]; + if (isIn(nr, nc) && !visited[nr][nc] && checkMove(cur.r, cur.c, nr, nc, dr[d], dc[d])) { + queue.offer(new Location(nr, nc)); + visited[nr][nc] = true; + } + } + } + count++; + } + System.out.println(-1); + } + + private static boolean isIn(int r, int c) { + return r >= 0 && c >= 0 && r + H <= N && c + W <= M; + } + + private static boolean checkMove(int oldR, int oldC, int newR, int newC, int dr, int dc) { + if (dr == -1) { + for (int j = 0; j < W; j++) { + if (map[newR][newC + j] == 1) + return false; + } + } else if (dr == 1) { + for (int j = 0; j < W; j++) { + if (map[newR + H - 1][newC + j] == 1) + return false; + } + } else if (dc == -1) { + for (int i = 0; i < H; i++) { + if (map[newR + i][newC] == 1) + return false; + } + } else if (dc == 1) { + for (int i = 0; i < H; i++) { + if (map[newR + i][newC + W - 1] == 1) + return false; + } + } + return true; + } +} \ No newline at end of file