From aaf81eb795920210de2d805e68daee5433434763 Mon Sep 17 00:00:00 2001 From: yeahdy Date: Fri, 6 Dec 2024 11:58:39 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[SQL]=20?= =?UTF-8?q?=EB=8C=80=EC=97=AC=20=ED=9A=9F=EC=88=98=EA=B0=80=20=EB=A7=8E?= =?UTF-8?q?=EC=9D=80=20=EC=9E=90=EB=8F=99=EC=B0=A8=EB=93=A4=EC=9D=98=20?= =?UTF-8?q?=EC=9B=94=EB=B3=84=20=EB=8C=80=EC=97=AC=20=ED=9A=9F=EC=88=98=20?= =?UTF-8?q?=EA=B5=AC=ED=95=98=EA=B8=B0=5F241203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...30 \352\265\254\355\225\230\352\270\260.sql" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "SQL/13\354\243\274\354\260\250/YJ_\353\214\200\354\227\254 \355\232\237\354\210\230\352\260\200 \353\247\216\354\235\200 \354\236\220\353\217\231\354\260\250\353\223\244\354\235\230 \354\233\224\353\263\204 \353\214\200\354\227\254 \355\232\237\354\210\230 \352\265\254\355\225\230\352\270\260.sql" diff --git "a/SQL/13\354\243\274\354\260\250/YJ_\353\214\200\354\227\254 \355\232\237\354\210\230\352\260\200 \353\247\216\354\235\200 \354\236\220\353\217\231\354\260\250\353\223\244\354\235\230 \354\233\224\353\263\204 \353\214\200\354\227\254 \355\232\237\354\210\230 \352\265\254\355\225\230\352\270\260.sql" "b/SQL/13\354\243\274\354\260\250/YJ_\353\214\200\354\227\254 \355\232\237\354\210\230\352\260\200 \353\247\216\354\235\200 \354\236\220\353\217\231\354\260\250\353\223\244\354\235\230 \354\233\224\353\263\204 \353\214\200\354\227\254 \355\232\237\354\210\230 \352\265\254\355\225\230\352\270\260.sql" new file mode 100644 index 00000000..7b2d0dce --- /dev/null +++ "b/SQL/13\354\243\274\354\260\250/YJ_\353\214\200\354\227\254 \355\232\237\354\210\230\352\260\200 \353\247\216\354\235\200 \354\236\220\353\217\231\354\260\250\353\223\244\354\235\230 \354\233\224\353\263\204 \353\214\200\354\227\254 \355\232\237\354\210\230 \352\265\254\355\225\230\352\270\260.sql" @@ -0,0 +1,17 @@ +-- 2022년 8월부터 2022년 10월까지 총 대여 횟수가 5회 이상인 자동차들에 대해서 +-- 해당 기간 동안의 월별 자동차 ID 별 총 대여 횟수(컬럼명: RECORDS) +-- 월을 기준으로 오름차순 정렬, 월이 같다면 자동차 ID를 기준으로 내림차순 정렬 +WITH CAR_COUNT AS( + SELECT CAR_ID + FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY + WHERE DATE_FORMAT(START_DATE,'%Y-%m') BETWEEN '2022-08' AND '2022-10' + GROUP BY CAR_ID + HAVING COUNT(CAR_ID) >= 5 +) +SELECT + MONTH(START_DATE) MONTH, CAR_ID, COUNT(CAR_ID) RECORDS +FROM CAR_RENTAL_COMPANY_RENTAL_HISTORY +WHERE CAR_ID IN (SELECT * FROM CAR_COUNT) + AND DATE_FORMAT(START_DATE,'%Y-%m') BETWEEN '2022-08' AND '2022-10' +GROUP BY MONTH(START_DATE), CAR_ID +ORDER BY MONTH(START_DATE), CAR_ID DESC \ No newline at end of file From bfdb515ddb621d186879fbae19e2a473cb1001fa Mon Sep 17 00:00:00 2001 From: yeahdy Date: Fri, 6 Dec 2024 11:59:46 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[SQL]=20Stud?= =?UTF-8?q?ents=20and=20Examinations=5F241205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YJ_Students and Examinations.sql" | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 "SQL/13\354\243\274\354\260\250/YJ_Students and Examinations.sql" diff --git "a/SQL/13\354\243\274\354\260\250/YJ_Students and Examinations.sql" "b/SQL/13\354\243\274\354\260\250/YJ_Students and Examinations.sql" new file mode 100644 index 00000000..1447c038 --- /dev/null +++ "b/SQL/13\354\243\274\354\260\250/YJ_Students and Examinations.sql" @@ -0,0 +1,8 @@ +SELECT + s.student_id, s.student_name, su.subject_name, COUNT(e.subject_name) attended_exams +FROM Students s +CROSS JOIN Subjects su +LEFT JOIN Examinations e +ON s.student_id = e.student_id AND su.subject_name = e.subject_name +GROUP BY s.student_id, s.student_name, su.subject_name +ORDER BY s.student_id, su.subject_name \ No newline at end of file From 2419c2bd0deab6cb64e00543593226a19a8b5647 Mon Sep 17 00:00:00 2001 From: yeahdy Date: Fri, 6 Dec 2024 17:53:48 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[CT]=20?= =?UTF-8?q?=EC=88=A0=EB=9E=98=EC=9E=A1=EA=B8=B0=20=EC=B2=B4=EC=8A=A4=5F241?= =?UTF-8?q?202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...352\270\260_\354\262\264\354\212\244.java" | 142 ++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 "CodeTree/2019-2020\353\205\204/YJ_\354\210\240\353\236\230\354\236\241\352\270\260_\354\262\264\354\212\244.java" diff --git "a/CodeTree/2019-2020\353\205\204/YJ_\354\210\240\353\236\230\354\236\241\352\270\260_\354\262\264\354\212\244.java" "b/CodeTree/2019-2020\353\205\204/YJ_\354\210\240\353\236\230\354\236\241\352\270\260_\354\262\264\354\212\244.java" new file mode 100644 index 00000000..49e2955b --- /dev/null +++ "b/CodeTree/2019-2020\353\205\204/YJ_\354\210\240\353\236\230\354\236\241\352\270\260_\354\262\264\354\212\244.java" @@ -0,0 +1,142 @@ + +import java.io.*; +import java.util.*; + +public class YJ_술래잡기_체스 { + static class Chess implements Comparable{ + int x; + int y; + int number; + int direction; + + Chess (int x, int y, int number, int direction){ + this.x = x; + this.y = y; + this.number = number; + this.direction = direction; + } + + @Override + public int compareTo(Chess c){ + return this.number - c.number; + } + } + + static final int NUM = 4; + static final Chess EMPTY = new Chess(0,0,0,0); + static Chess[][] game = new Chess[NUM][NUM]; + static PriorityQueue pq = new PriorityQueue<>(); + static int score = 0; + static Chess tagger; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + //초기값 세팅 + for(int i=0; i deque = new ArrayDeque<>(); + Chess maxThief = EMPTY; + + boolean[][] visited = new boolean[NUM][NUM]; + deque.offer(tagger); + visited[tagger.x][tagger.y] = true; + + while(!deque.isEmpty()){ + Chess tagger = deque.poll(); + for (int i=0; i<8; i++){ + int tempX = tagger.x + nx[i]; + int tempY = tagger.y + ny[i]; + //술래말은 도둑말이 없는 곳으로는 이동할 수 없습니다 + if(stop(tempX,tempY) || visited[tagger.x][tagger.y] || game[tempX][tempY].number == 0){ + continue; + } + + visited[tagger.x][tagger.y] = true; + Chess thief = game[tempX][tempY]; + deque.offer(thief); + if(thief.number > maxThief.number){ + maxThief = thief; + } + } + } + + if(maxThief.number != 0){ + game[tagger.x][tagger.y] = EMPTY; //기존에 술래가 있던 위치 빈공간으로 만들기 + //술래 위치 이동 + score += maxThief.number; + tagger = game[maxThief.x][maxThief.y]; + game[maxThief.x][maxThief.y] = null; + return true; + } + return false; //도둑말을 잡지 못했다면 게임 종료 + } + + + private static boolean stop(int x, int y){ + return x < 0 || x >= NUM || y < 0 || y >= NUM; + } +} From 73ff5cd68a841514f305140c471e54ef9919977a Mon Sep 17 00:00:00 2001 From: yeahdy Date: Sat, 7 Dec 2024 00:28:44 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[BOJ]=201194?= =?UTF-8?q?=20=20=EB=8B=AC=EC=9D=B4=20=EC=B0=A8=EC=98=A4=EB=A5=B8=EB=8B=A4?= =?UTF-8?q?,=20=EA=B0=80=EC=9E=90=5F241203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000\353\262\210/YJ_1194.java" | 100 +++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 "BOJ/1000-5000\353\262\210/YJ_1194.java" diff --git "a/BOJ/1000-5000\353\262\210/YJ_1194.java" "b/BOJ/1000-5000\353\262\210/YJ_1194.java" new file mode 100644 index 00000000..e95c81ab --- /dev/null +++ "b/BOJ/1000-5000\353\262\210/YJ_1194.java" @@ -0,0 +1,100 @@ +import java.io.*; +import java.util.*; + +//bfs + 비트마스킹 +//처음에 dfs 로 접근했는데, 그럼 모든 경로를 다 탐색 해 버리더라구요 최단거리 문제는 bfs 로 풀기! +public class YJ_1194 { + static class Pos { + int x; + int y; + int distance; + int hasKey; + + public Pos(int x, int y, int distance, int hasKey) { + this.x = x; + this.y = y; + this.distance = distance; + this.hasKey = hasKey; + } + } + + static final char EXIT = '1'; + static final char CURRENT = '0'; + static final char WALL = '#'; + + static int N; + static int M; + static char[][] maze; + + 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()); + M = Integer.parseInt(st.nextToken()); + maze = new char[N][M]; + visited = new boolean[N][M][64]; //★키 6개 2^6 = 64 + + int x = 0; + int y = 0; + for(int i=0; i pq = new ArrayDeque<>(); + int[] dx = {0,1,0,-1}; + int[] dy = {1,0,-1,0}; + + pq.offer(new Pos(x,y,0,0)); + visited[x][y][0] = true; + + while(!pq.isEmpty()) { + Pos pos = pq.poll(); + if(maze[pos.x][pos.y] == EXIT) { + return pos.distance; + } + + for(int d=0; d<4; d++){ + int nx = pos.x + dx[d]; + int ny = pos.y + dy[d]; + if(stop(nx,ny, pos.hasKey)){ + continue; + } + + int key = pos.hasKey; + if(maze[nx][ny] >= 'A' && maze[nx][ny] <= 'F') { + if((key & 1<<(maze[nx][ny] - 'A')) > 0){ //가지고 있는 키와 일치하는 경우 (A=65) + visited[nx][ny][key] = true; + }else{ + continue; + } + }else if(maze[nx][ny] >= 'a' && maze[nx][ny] <= 'f'){ //키를 주운 경우 + key |= 1<<(maze[nx][ny] - 'a'); //a=97 + visited[nx][ny][key] = true; + }else{ + visited[nx][ny][key] = true; //'.' + } + + pq.offer(new Pos(nx,ny,pos.distance+1,key)); + } + } + + return -1; + } + + static private boolean stop(int x, int y, int hasKey){ + return x < 0 || x >= N || y < 0 || y >= M || maze[x][y] == WALL || visited[x][y][hasKey]; + } + +} \ No newline at end of file From e65c4c36314493b6039d0296561daefd1ac16749 Mon Sep 17 00:00:00 2001 From: yeahdy Date: Sat, 7 Dec 2024 01:24:07 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[BOJ]=208979?= =?UTF-8?q?=20=EC=98=AC=EB=A6=BC=ED=94=BD=5F241204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/5001-10000\353\262\210/YJ_8979.java" | 75 +++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 "BOJ/5001-10000\353\262\210/YJ_8979.java" diff --git "a/BOJ/5001-10000\353\262\210/YJ_8979.java" "b/BOJ/5001-10000\353\262\210/YJ_8979.java" new file mode 100644 index 00000000..e46d0aa1 --- /dev/null +++ "b/BOJ/5001-10000\353\262\210/YJ_8979.java" @@ -0,0 +1,75 @@ +import java.io.*; +import java.util.*; + +public class YJ_8979 { + static class Nation implements Comparable { + int name; + int gold; + int silver; + int bronze; + + public Nation(int name, int gold, int silver, int bronze) { + this.name = name; + this.gold = gold; + this.silver = silver; + this.bronze = bronze; + } + + @Override + public int compareTo(Nation o) { + if(this.gold == o.gold){ + if(this.silver == o.silver){ + return o.bronze - this.bronze; + } + return o.silver - this.silver; + } + return o.gold - this.gold; + } + } + + static PriorityQueue pq = new PriorityQueue<>(); + 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()); + + for(int i=0; i Date: Sat, 7 Dec 2024 03:22:59 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[BOJ]=201749?= =?UTF-8?q?=20=EC=A0=90=EC=88=98=EB=94=B0=EB=A8=B9=EA=B8=B0=5F241204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000\353\262\210/YJ_1749.java" | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "BOJ/1000-5000\353\262\210/YJ_1749.java" diff --git "a/BOJ/1000-5000\353\262\210/YJ_1749.java" "b/BOJ/1000-5000\353\262\210/YJ_1749.java" new file mode 100644 index 00000000..462d3e32 --- /dev/null +++ "b/BOJ/1000-5000\353\262\210/YJ_1749.java" @@ -0,0 +1,37 @@ +import java.io.*; +import java.util.*; + +public class YJ_1749 { + 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())+1; + int M = Integer.parseInt(st.nextToken())+1; + int [][] game = new int[N][M]; + + for(int i = 1; i < N; i++) { + st = new StringTokenizer(br.readLine()); + for(int j = 1; j < M; j++) { + game[i][j] = Integer.parseInt(st.nextToken()); + } + } + //누적합 + for(int i = 1; i < N; i++) { + for(int j = 1; j < M; j++) { + game[i][j] = game[i-1][j] + game[i][j-1] - game[i-1][j-1] + game[i][j]; + } + } + + int max = game[1][1]; + for(int i = 1; i < N; i++) { + for(int j = 1; j < M; j++) { + for(int r = 0; r < i; r++) { + for(int k = 0; k < j; k++) { + max = Math.max(max, game[i][j] - game[r][j] - game[i][k] + game[r][k]); + } + } + } + } + System.out.println(max); + } +} \ No newline at end of file From aef4beb0c46ee091e91962dddc14a6e4144b199c Mon Sep 17 00:00:00 2001 From: yeahdy Date: Sat, 7 Dec 2024 03:46:56 +0900 Subject: [PATCH 7/7] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[PG]=2025013?= =?UTF-8?q?5=20=EC=95=84=EB=82=A0=EB=A1=9C=EA=B7=B8=20=EC=8B=9C=EA=B3=84?= =?UTF-8?q?=5F241205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Level2/YJ_250135.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Programmers/Level2/YJ_250135.java diff --git a/Programmers/Level2/YJ_250135.java b/Programmers/Level2/YJ_250135.java new file mode 100644 index 00000000..81522281 --- /dev/null +++ b/Programmers/Level2/YJ_250135.java @@ -0,0 +1,29 @@ +public class YJ_250135 { + public int solution(int h1, int m1, int s1, int h2, int m2, int s2) { + int answer = getAlarms(h2,m2,s2)-getAlarms(h1,m1,s1); + return s1==0 && m1==0? answer+1 : answer; + } + + int getAlarms(int h, int m, int s){ + int alarms = 0; + + int mCount = h * (60-1) + m; //1시간에 59번(60분 제외) + 1분당 1번 + int hCount = h * 60 + m; + if(h>=12) { + hCount--; //24시인 경우 -1 + } + + + //초침과 분침이 겹칠 경우 + if(s*6 >= m*6 + s*0.1){ // 초침의 각도 = s * 360/60 , 분침의 각도 = m * 360/60 + s * 360/(60*60) + mCount++; + } + //초침과 시침이 겹칠 경우 + if(30*(h%12) + 0.5*m + s * ((double) 1 / 120) <= s*6){ // 시침의 각도 = (h%12) * 360/12 + m * 360/(12*60) + s * 360 / (12*60*60) + hCount++; + } + + alarms = mCount + hCount; + return h>=12? alarms-1 : alarms; + } +}