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 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{ + 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); + + } + +} 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 によって変換されたページ (->オリジナル) /