From 0b34228b96879f06be1fd322728e2f313fc6227b Mon Sep 17 00:00:00 2001 From: yeahdy Date: 2024年11月27日 00:35:40 +0900 Subject: [PATCH 1/9] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[BOJ]=202870?= =?UTF-8?q?7=20=EB=B0=B0=EC=97=B4=EC=A0=95=EB=A0=AC=5F241126?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/30000-35000353円262円210円/YJ_28707.java" | 129 ++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 "BOJ/30000-35000353円262円210円/YJ_28707.java" diff --git "a/BOJ/30000-35000353円262円210円/YJ_28707.java" "b/BOJ/30000-35000353円262円210円/YJ_28707.java" new file mode 100644 index 00000000..382fedfa --- /dev/null +++ "b/BOJ/30000-35000353円262円210円/YJ_28707.java" @@ -0,0 +1,129 @@ +import java.io.*; +import java.util.*; + +//2 <= N <= 8 으로 조합 경우의 수 8!> 40320개 +//1 <= A <= 10 +public class YJ_28707 { + static class Controller { + int l; + int r; + int c; + + public Controller(int l, int r, int c) { + this.l = l; + this.r = r; + this.c = c; + } + } + + static class Node implements Comparable{ + int v; + int c; + + public Node(int v, int c) { + this.v = v; + this.c = c; + } + + @Override + public int compareTo(Node o){ + return this.c - o.c; + } + } + + static int n; + static int answer; + static List list = new ArrayList(); + static Map table = new HashMap(); //<배열,최단거리> 저장 테이블 + static PriorityQueue pq = new PriorityQueue(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + n = Integer.parseInt(br.readLine()); + + //배열 입력값 초기화 + StringTokenizer st = new StringTokenizer(br.readLine()); + StringBuilder sb = new StringBuilder(); + int[] arr = new int[n]; + for(int i=0; i= 0; i--) { + if(v % 10 == 0){ // 10,20,30.. 등의 두 자릿수 배수가 있다는 뜻 (ex. 1410) + arr[i] = v % 100; //두 자릿수를 배열에 저장 + v /= 100; + } else{ //단일 자릿수일 경우 기존 자릿수 유지 + arr[i] = v % 10; + v /= 10; + } + } + + //조작에 맞춰서 자리 교체 + int l = controller.l; + int r = controller.r; + int temp = arr[l]; + arr[l] = arr[r]; + arr[r] = temp; + + return arrToInt(arr); + } + + static StringBuilder sb = new StringBuilder(); + private static int arrToInt(int[] arr) { + for(int num : arr){ + sb.append(num); + } + int result = Integer.parseInt(sb.toString()); + sb.setLength(0); + return result; + } +} \ No newline at end of file From 3aab10e725376896306423404a2b355a0d482c68 Mon Sep 17 00:00:00 2001 From: yeahdy Date: 2024年11月27日 02:05:26 +0900 Subject: [PATCH 2/9] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[SQL]=20Prod?= =?UTF-8?q?uct=20Price=20at=20a=20Given=20Date=5F241126?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YJ_Product Price at a Given Date.sql" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 "SQL/12354円243円274円354円260円250円/YJ_Product Price at a Given Date.sql" diff --git "a/SQL/12354円243円274円354円260円250円/YJ_Product Price at a Given Date.sql" "b/SQL/12354円243円274円354円260円250円/YJ_Product Price at a Given Date.sql" new file mode 100644 index 00000000..1a2492b9 --- /dev/null +++ "b/SQL/12354円243円274円354円260円250円/YJ_Product Price at a Given Date.sql" @@ -0,0 +1,21 @@ +SELECT + DISTINCT p.product_id, + CASE + WHEN distinct_p.product_id IS NULL THEN 10 + ELSE p.new_price + END AS price +FROM Products p +LEFT JOIN ( + SELECT product_id, MAX(change_date) change_date + FROM Products + WHERE change_date < '2019-08-17' + GROUP BY product_id +) sub +ON p.product_id = sub.product_id AND p.change_date = sub.change_date +LEFT JOIN ( + SELECT DISTINCT product_id + FROM Products + WHERE change_date < '2019-08-17' +) distinct_p +ON p.product_id = distinct_p.product_id +WHERE sub.change_date IS NOT NULL OR distinct_p.product_id IS NULL \ No newline at end of file From e7dd7a79be0d92e1f431cdd37cfc403cdb7d5438 Mon Sep 17 00:00:00 2001 From: yeahdy Date: 2024年11月27日 23:09:03 +0900 Subject: [PATCH 3/9] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[CT]=20?= =?UTF-8?q?=EC=83=9D=EB=AA=85=EA=B3=BC=ED=95=99=EB=B6=80=5F=EB=9E=A9=5F?= =?UTF-8?q?=EC=9D=B8=ED=84=B4=5F241125?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...353236円251円_354円235円270円355円204円264円.java" | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 "CodeTree/2019-2020353円205円204円/YJ_354円203円235円353円252円205円352円263円274円355円225円231円353円266円200円_353円236円251円_354円235円270円355円204円264円.java" diff --git "a/CodeTree/2019-2020353円205円204円/YJ_354円203円235円353円252円205円352円263円274円355円225円231円353円266円200円_353円236円251円_354円235円270円355円204円264円.java" "b/CodeTree/2019-2020353円205円204円/YJ_354円203円235円353円252円205円352円263円274円355円225円231円353円266円200円_353円236円251円_354円235円270円355円204円264円.java" new file mode 100644 index 00000000..fb8e1be6 --- /dev/null +++ "b/CodeTree/2019-2020353円205円204円/YJ_354円203円235円353円252円205円352円263円274円355円225円231円353円266円200円_353円236円251円_354円235円270円355円204円264円.java" @@ -0,0 +1,131 @@ +import java.io.*; +import java.util.*; + +//2 ≤ n, m ≤ 100> 10^4 +public class YJ_생명과학부_랩_인턴 { + static class Mold { + int x; + int y; + int s; //이동거리 + int d; //이동방향 + int b; //곰팡이 크기 + + Mold(int x, int y, int s, int d, int b){ + this.x = x; + this.y = y; + this.s = calculateS(s,d); + this.d = d; + this.b = b; + } + + private int calculateS(int s, int d){ + if(d<=1){ + return s % (2*n-2); + }else{ + return s % (2*m-2); + } + } + + public void changeD(){ + //위(1)↔아래(2) , 오른쪽(3)↔왼쪽(4) + this.d = this.d%2 == 0? this.d+1 : this.d-1; + } + + public boolean isBiggerThan(Mold m){ + if(Objects.isNull(m)){ + return true; + } + return this.b> m.b; + } + } + + static Mold[][] lab; + static List inventory = new ArrayList(); //인턴이 채취한 곰팡이들 + static int n; + static int m; + 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()); + int k = Integer.parseInt(st.nextToken()); + + if(k == 0){ + System.out.println(0); + }else{ + lab = new Mold[n][m]; + for(int i=0; i mold.b).sum()); + } + } + + //곰팡이 채취하기 + //열의 위에서 아래로 내려가며 탐색할 때 제일 빨리 발견한 곰팡이를 채취 + public static void search(int j){ + for(int i=0; i lab 으로 옮기기 : 기존의 lab 에서 곰팡이를 이동시키면 중복 이동이 발생할 수도 있음 + lab = tempLab; + } + + private static Mold move(Mold mold){ + //위 아래 오른쪽 왼쪽 + int[] nx = {-1,1,0,0}; + int[] ny = {0,0,1,-1}; + //거리만큼 이동 + int tempS = mold.s; + while(tempS--> 0){ + int x = mold.x + nx[mold.d]; + int y = mold.y + ny[mold.d]; + //격자 범위를 벗어날 경우 방향전환 + if(x < 0 || y < 0 || x>= n || y>= m){ + mold.changeD(); + mold.x = mold.x + nx[mold.d]; + mold.y = mold.y + ny[mold.d]; + }else{ //격자 범위 내일 경우 그대로 이동 + mold.x = x; + mold.y = y; + } + } + return mold; + } +} \ No newline at end of file From 65c48c2e4e91f8c7161113e8072ce7937fb20998 Mon Sep 17 00:00:00 2001 From: yeahdy Date: 2024年11月27日 23:59:46 +0900 Subject: [PATCH 4/9] =?UTF-8?q?chore:=20=EC=9D=B4=EC=98=88=EC=A7=84:=20[CT?= =?UTF-8?q?]=20=EC=83=9D=EB=AA=85=EA=B3=BC=ED=95=99=EB=B6=80=5F=EB=9E=A9?= =?UTF-8?q?=5F=EC=9D=B8=ED=84=B4=5F241125=20=EC=A3=BC=EC=84=9D=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...31353円266円200円_353円236円251円_354円235円270円355円204円264円.java" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/CodeTree/2019-2020353円205円204円/YJ_354円203円235円353円252円205円352円263円274円355円225円231円353円266円200円_353円236円251円_354円235円270円355円204円264円.java" "b/CodeTree/2019-2020353円205円204円/YJ_354円203円235円353円252円205円352円263円274円355円225円231円353円266円200円_353円236円251円_354円235円270円355円204円264円.java" index fb8e1be6..e2e26010 100644 --- "a/CodeTree/2019-2020353円205円204円/YJ_354円203円235円353円252円205円352円263円274円355円225円231円353円266円200円_353円236円251円_354円235円270円355円204円264円.java" +++ "b/CodeTree/2019-2020353円205円204円/YJ_354円203円235円353円252円205円352円263円274円355円225円231円353円266円200円_353円236円251円_354円235円270円355円204円264円.java" @@ -27,7 +27,7 @@ private int calculateS(int s, int d){ } public void changeD(){ - //위(1)↔아래(2) , 오른쪽(3)↔왼쪽(4) + //위(0)↔아래(1) , 오른쪽(2)↔왼쪽(3) this.d = this.d%2 == 0? this.d+1 : this.d-1; } @@ -69,7 +69,7 @@ public static void main(String[] args) throws IOException { search(i); moveMolds(); } - //인턴이 채취한 곰팡9이 크기 + //인턴이 채취한 곰팡이 크기 System.out.println(inventory.stream().mapToInt(mold -> mold.b).sum()); } } From a773b36cd5a54c9419081251ba03264b0f50ddde Mon Sep 17 00:00:00 2001 From: yeahdy Date: 2024年11月28日 10:29:38 +0900 Subject: [PATCH 5/9] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[PG]=2064064?= =?UTF-8?q?=20=EB=B6=88=EB=9F=89=20=EC=82=AC=EC=9A=A9=EC=9E=90=5F241127?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Level3/YJ_64064.java | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Programmers/Level3/YJ_64064.java diff --git a/Programmers/Level3/YJ_64064.java b/Programmers/Level3/YJ_64064.java new file mode 100644 index 00000000..55dc9c7a --- /dev/null +++ b/Programmers/Level3/YJ_64064.java @@ -0,0 +1,48 @@ +import java.util.*; + +//user_id 배열의 크기는 1 이상 8 이하> 8! +public class YJ_64064 { + HashSet set = new HashSet(); + String[] userIds; + String[] bannedIds; + boolean[] visited; + + public int solution(String[] user_id, String[] banned_id) { + for(int i=0; i Date: 2024年11月28日 12:19:06 +0900 Subject: [PATCH 6/9] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[SQL]=20Trip?= =?UTF-8?q?s=20and=20Users=5F241128?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YJ_Trips and Users.sql" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "SQL/12354円243円274円354円260円250円/YJ_Trips and Users.sql" diff --git "a/SQL/12354円243円274円354円260円250円/YJ_Trips and Users.sql" "b/SQL/12354円243円274円354円260円250円/YJ_Trips and Users.sql" new file mode 100644 index 00000000..8136c5b2 --- /dev/null +++ "b/SQL/12354円243円274円354円260円250円/YJ_Trips and Users.sql" @@ -0,0 +1,18 @@ +WITH NOT_BANNED AS( + SELECT users_id + FROM Users + WHERE banned = 'No' +) +SELECT + request_at Day, + ROUND( + SUM(CASE + WHEN status LIKE 'cancelled_by%' THEN 1 + ELSE 0 + END) / COUNT(id) + ,2) 'Cancellation Rate' +FROM Trips t +WHERE t.client_id IN (SELECT users_id FROM NOT_BANNED) + AND t.driver_id IN (SELECT users_id FROM NOT_BANNED) + AND request_at BETWEEN '2013-10-01' AND '2013-10-03' +GROUP BY request_at \ No newline at end of file From cea060cbe8a48da997383e6d32b911b4d431550f Mon Sep 17 00:00:00 2001 From: yeahdy Date: 2024年11月29日 10:55:25 +0900 Subject: [PATCH 7/9] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[BOJ]=202352?= =?UTF-8?q?=20=EB=B0=98=EB=8F=84=EC=B2=B4=20=EC=84=A4=EA=B3=84=5F241127?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/YJ_2352.java" | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/YJ_2352.java" diff --git "a/BOJ/1000-5000353円262円210円/YJ_2352.java" "b/BOJ/1000-5000353円262円210円/YJ_2352.java" new file mode 100644 index 00000000..900c15a7 --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/YJ_2352.java" @@ -0,0 +1,44 @@ +import java.io.*; +import java.util.*; + +public class YJ_2352 { + static List lis = new ArrayList(); + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int n = Integer.parseInt(br.readLine()); + StringTokenizer st = new StringTokenizer(br.readLine()); + //초기화 + int[] connection = new int[n+1]; + for(int i=1; i 더 넓은 범위 에서 연결할 수 있는 선을 찾는다 + }else{ + end = mid; //end 간격을 조정하면 mid 가 작아진다> 연결을 더 많이 할 수 있다 + } + } + return end; + } + //lower bound: mid 값보다 크거나 같을때 end 는 중간값과 같은 위치에 있음 +} \ No newline at end of file From f0d09a35d133c05b3c4a29a3190bf128a88b10cf Mon Sep 17 00:00:00 2001 From: yeahdy Date: 2024年11月30日 02:36:34 +0900 Subject: [PATCH 8/9] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[BOJ]=202533?= =?UTF-8?q?=20=EC=82=AC=ED=9A=8C=EB=A7=9D=20=EC=84=9C=EB=B9=84=EC=8A=A4(SN?= =?UTF-8?q?S)=5F241129?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/YJ_2533.java" | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/YJ_2533.java" diff --git "a/BOJ/1000-5000353円262円210円/YJ_2533.java" "b/BOJ/1000-5000353円262円210円/YJ_2533.java" new file mode 100644 index 00000000..68f589dc --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/YJ_2533.java" @@ -0,0 +1,45 @@ +import java.io.*; +import java.util.*; + +public class YJ_2533 { + static List[] graph; + static int[][] dp; //dp[index][0] : 얼리 아답터 X , dp[index][1] : 얼리 아답터 O + static boolean[] visited; + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int n = Integer.parseInt(br.readLine()); + + dp = new int[n+1][2]; + visited = new boolean[n+1]; + graph = new ArrayList[n+1]; + for(int i = 1; i < n+1; i++) { + graph[i] = new ArrayList(); + } + for(int i = 0; i < n-1; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + int u = Integer.parseInt(st.nextToken()); + int v = Integer.parseInt(st.nextToken()); + graph[u].add(v); + graph[v].add(u); + } + + dfs(1); + System.out.println(Math.min(dp[1][0], dp[1][1])); + } + + static void dfs(int u) { + visited[u] = true; + dp[u][0] = 0; //얼리 아답터 X + dp[u][1] = 1; //얼리 아답터 O + + for(int i=0; i Date: 2024年11月30日 02:37:44 +0900 Subject: [PATCH 9/9] =?UTF-8?q?=EC=9D=B4=EC=98=88=EC=A7=84:=20[PG]=2017686?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=EB=AA=85=20=EC=A0=95=EB=A0=AC=5F241129?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Level2/YJ_17686.java | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Programmers/Level2/YJ_17686.java diff --git a/Programmers/Level2/YJ_17686.java b/Programmers/Level2/YJ_17686.java new file mode 100644 index 00000000..7ed3d557 --- /dev/null +++ b/Programmers/Level2/YJ_17686.java @@ -0,0 +1,56 @@ +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +//정규식 문자열 +public class YJ_17686 { + static class File implements Comparable{ + String head; + String num; + String tail; + + public File(String head, String num, String tail) { + this.head = head; + this.num = num; + this.tail = tail; + } + + @Override + public int compareTo(File o) { + //1. HEAD 사전순으로 정렬, 대소문자 구분X 2. NUMBER의 숫자 순으로 정렬 + int order = this.head.toLowerCase().compareTo(o.head.toLowerCase()); + return order == 0 ? Integer.parseInt(this.num) - Integer.parseInt(o.num) : order; + } + } + + public String[] solution(String[] files) { + List fileList = new ArrayList(); + //HEAD는 숫자가 아닌 문자로 이루어져 있으며, 최소한 한 글자 이상이다. + //NUMBER는 한 글자에서 최대 다섯 글자 사이의 연속된 숫자 (0~9) + final String regex = "([a-zA-Z\\s\\-]+)([0-9]{1,5})(.*)"; + + for(String file : files){ + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(file); + while(matcher.find()){ + //TAIL은 자가 다시 나타날 수도 있으며, 아무 글자도 없을 수 있다. + if(matcher.group(3).isEmpty()){ + fileList.add(new File(matcher.group(1),matcher.group(2),"")); + }else{ + fileList.add(new File(matcher.group(1),matcher.group(2),matcher.group(3))); + } + } + } + Collections.sort(fileList); + //파일명 조합 + String[] answer = new String[fileList.size()]; + StringBuilder sb = new StringBuilder(); + for(int i = 0; i < fileList.size(); i++){ + answer[i] = sb.append(fileList.get(i).head) + .append(fileList.get(i).num) + .append(fileList.get(i).tail).toString(); + sb.setLength(0); + } + return answer; + } +}

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