From 36d9353fb93dc9b6e56e40b88c288464fa316f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81?= Date: 2025年1月20日 15:15:20 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[BOJ]=201938?= =?UTF-8?q?=20=ED=86=B5=EB=82=98=EB=AC=B4=20=EC=98=AE=EA=B8=B0=EA=B8=B0=5F?= =?UTF-8?q?250120?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/JY_1938.java" | 147 +++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/JY_1938.java" diff --git "a/BOJ/1000-5000353円262円210円/JY_1938.java" "b/BOJ/1000-5000353円262円210円/JY_1938.java" new file mode 100644 index 00000000..c3ebfad3 --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/JY_1938.java" @@ -0,0 +1,147 @@ +import java.io.*; +import java.util.*; + +public class JY_1938 { + + static int N; + static char[][] g; + // 상, 좌, 하, 우 + static int[] dx = {-1, 0, 1, 0}; + static int[] dy = {0, -1, 0, 1}; + static int ans; + static class Step { + int x, y; + int dir; // 세로: 0, 가로: 1 + int cnt; + public Step(int x, int y, int dir, int cnt) { + super(); + this.x = x; + this.y = y; + this.dir = dir; + this.cnt = cnt; + } + @Override + public String toString() { + return "Step [x=" + x + ", y=" + y + ", dir=" + dir + ", cnt=" + cnt + "]"; + } + + } + + + 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()); + g = new char[N][N]; + + List bList = new ArrayList(); + for(int i=0; i=0 && x=0 && y q = new LinkedList(); + + q.add(new Step(sx, sy, sDir, 0)); + visited[sx][sy][sDir] = true; + + while(!q.isEmpty()) { + Step now = q.poll(); + + if(isExit(now.x, now.y, now.dir)) { + ans = now.cnt; + break; + } + + // U, L, D, R + for(int i=0; i<4; i++) { + int nx = now.x + dx[i]; + int ny = now.y + dy[i]; + + // 중심 통나무 체크 + if(!inRange(nx, ny)) continue; + if(visited[nx][ny][now.dir]) continue; + if(g[nx][ny] == '1') continue; + + + // 나머지 통나무들 체크 + int ax = nx + dx[now.dir]; + int ay = ny + dy[now.dir]; + int bx = nx + dx[now.dir+2]; + int by = ny + dy[now.dir+2]; + if(!inRange(ax, ay) || !inRange(bx, by)) continue; + if(g[ax][ay] == '1' || g[bx][by] == '1') continue; + + // 이동가능 + visited[nx][ny][now.dir] = true; + q.add(new Step(nx, ny, now.dir, now.cnt+1)); + } + + if(!canTurn(now.x, now.y)) continue; + // turn + int nDir = Math.abs(now.dir-1); + if(visited[now.x][now.y][nDir]) continue; // 회전한 방향으로 회전한 적이 있음 + int ax = now.x + dx[nDir]; + int ay = now.y + dy[nDir]; + int bx = now.x + dx[nDir+2]; + int by = now.y + dy[nDir+2]; + if(!inRange(ax, ay) || !inRange(bx, by)) continue; + if(g[ax][ay] == '1' || g[bx][by] == '1') continue; + + visited[now.x][now.y][nDir] = true; + q.add(new Step(now.x, now.y, nDir, now.cnt+1)); + } + + } + public static boolean canTurn(int x, int y) { + for(int i=x-1; i Date: 2025年1月21日 16:22:51 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[BOJ]=201333?= =?UTF-8?q?4=20=EC=B2=A0=EB=A1=9C=5F250121?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/10001-15000353円262円210円/JY_13334.java" | 74 +++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 "BOJ/10001-15000353円262円210円/JY_13334.java" diff --git "a/BOJ/10001-15000353円262円210円/JY_13334.java" "b/BOJ/10001-15000353円262円210円/JY_13334.java" new file mode 100644 index 00000000..11002d52 --- /dev/null +++ "b/BOJ/10001-15000353円262円210円/JY_13334.java" @@ -0,0 +1,74 @@ +import java.io.*; +import java.util.*; + +public class JY_13334 { + + static int N; + static long D; + static class Pos implements Comparable{ + long h, o; + + public Pos(long h, long o) { + super(); + this.h = h; + this.o = o; + } + + // 끝점 기준으로 정렬 + @Override + public int compareTo(Pos other) { + return (int)(this.o - other.o); + } + + @Override + public String toString() { + return "Pos [h=" + h + ", o=" + o + "]"; + } + + } + + + 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()); + + // 끝점이 작은 순으로 정렬 => 시작점만 신경쓰면됨 + // 반대로) 시작점 기준으로 정렬하면, 시작점이 이동할 때 이전 것들의 시작점, 끝점을 모두 신경써줘야 함 + PriorityQueue pq = new PriorityQueue(); + for(int i=0; i tpq = new PriorityQueue(); + while(!pq.isEmpty()) { + Pos now = pq.poll(); + long start = now.o - D; + tpq.add(now.h); + + while(!tpq.isEmpty() && tpq.peek() < start) { + // 현재 시작지점 보다 작은 시작점들은 현재 구간에 포함될 수 없음 + tpq.poll(); + } + + ans = Math.max(ans, tpq.size()); + } + + System.out.println(ans); + + } + +} From 2769e6668f88212d9d6a3608caa3f85f708e16c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81?= Date: 2025年1月23日 12:48:56 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[BOJ]=201405?= =?UTF-8?q?=20=EB=AF=B8=EC=B9=9C=20=EB=A1=9C=EB=B4=87=5F250123?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/JY_1405.java" | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/JY_1405.java" diff --git "a/BOJ/1000-5000353円262円210円/JY_1405.java" "b/BOJ/1000-5000353円262円210円/JY_1405.java" new file mode 100644 index 00000000..2084b332 --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/JY_1405.java" @@ -0,0 +1,56 @@ +import java.io.*; +import java.util.*; + +public class JY_1405 { + + static int N, M; + static double[] arr; + static boolean[][] visited; + // 동 서 남 북 + static int[] dx = {0, 0, 1, -1}; + static int[] dy = {1, -1, 0, 0}; + static double ans; + + 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()); + + arr = new double[4]; + for(int i=0; i<4; i++) { + arr[i] = Integer.parseInt(st.nextToken()) * 0.01; + } + + // N <= 14 이므로 상하좌우 방향으로 최대 14까지 갈 수 있으므로 보드판 크기: 30 + M = 30; + visited = new boolean[M][M]; + visited[M/2][M/2] = true; + ans = 0; + dfs(M/2, M/2, 0, 1); + + System.out.println(ans); + } + public static boolean inRange(int x, int y) { + return x>=0 && x=0 && y Date: 2025年1月24日 16:35:41 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[SQL]=20Mont?= =?UTF-8?q?ly=20Transaction=201=5F250124?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JY_Montly_Transactions_1.sql" | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 "SQL/19354円243円274円354円260円250円/JY_Montly_Transactions_1.sql" diff --git "a/SQL/19354円243円274円354円260円250円/JY_Montly_Transactions_1.sql" "b/SQL/19354円243円274円354円260円250円/JY_Montly_Transactions_1.sql" new file mode 100644 index 00000000..74265b06 --- /dev/null +++ "b/SQL/19354円243円274円354円260円250円/JY_Montly_Transactions_1.sql" @@ -0,0 +1,9 @@ +-- 1193. Monthly Transactions I +-- https://leetcode.com/problems/monthly-transactions-i/ +SELECT DATE_FORMAT(trans_date, "%Y-%m") AS month, country + , COUNT(*) AS trans_count + , COUNT(IF(state = 'approved', state, NULL)) AS approved_count + , SUM(amount) AS trans_total_amount + , SUM(IF(state = 'approved', amount, 0)) AS approved_total_amount +FROM TRANSACTIONS +GROUP BY YEAR(trans_date), MONTH(trans_date), country \ No newline at end of file

AltStyle によって変換されたページ (->オリジナル) /