From bb6cff3a2d68f207af7e0fff969d5dd1c1cdee39 Mon Sep 17 00:00:00 2001 From: yeong Date: Tue, 29 Oct 2024 10:03:06 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[BOJ]=201911?= =?UTF-8?q?=20=ED=9D=99=EA=B8=B8=20=EB=B3=B4=EC=88=98=ED=95=98=EA=B8=B0=5F?= =?UTF-8?q?241029?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000\353\262\210/JY_1911.java" | 72 ++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 "BOJ/1000-5000\353\262\210/JY_1911.java" diff --git "a/BOJ/1000-5000\353\262\210/JY_1911.java" "b/BOJ/1000-5000\353\262\210/JY_1911.java" new file mode 100644 index 00000000..7b11d13e --- /dev/null +++ "b/BOJ/1000-5000\353\262\210/JY_1911.java" @@ -0,0 +1,72 @@ +package day1029; + +import java.io.*; +import java.util.*; + +public class JY_1911 { + + static int N, L; + static long[][] hrr; + + 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()); + L = Integer.parseInt(st.nextToken()); + + hrr = new long[N][2]; + for(int i=0; iLong.compare(o1[0], o2[0])); + + long s = 0; + long e = hrr[N-1][1]; // 최대의 널빤지수 == L이 1이고, 가장 마지막 물웅덩이까지 다 덮을 때 + long cnt = 0; + + while(s <= e) { + long mid = (s + e) / 2; + + if(isPossible(mid)) { + cnt = mid; + e = mid - 1; + }else { + s = mid + 1; + } + } + + System.out.println(cnt); + + } + public static boolean isPossible(long mid) { + long pre = 0; // 마지막 널빤지 위치 + long total = 0; // 총 필요한 널빤지 개수 + for(int i=0; i mid) return false; + + pre = pre + cnt * L; // 마지막 널빤지 위치 갱신 + } + + return true; + } + +} From 91b855b238a68903f8a055a185880660b86bfad2 Mon Sep 17 00:00:00 2001 From: yeong Date: Tue, 29 Oct 2024 10:58:32 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[BOJ]=209342?= =?UTF-8?q?=20=EC=97=BC=EC=83=89=EC=B2=B4=5F241029?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/5001-10000\353\262\210/JY_9342.java" | 72 +++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 "BOJ/5001-10000\353\262\210/JY_9342.java" diff --git "a/BOJ/5001-10000\353\262\210/JY_9342.java" "b/BOJ/5001-10000\353\262\210/JY_9342.java" new file mode 100644 index 00000000..c6d1cbac --- /dev/null +++ "b/BOJ/5001-10000\353\262\210/JY_9342.java" @@ -0,0 +1,72 @@ +package day1029; + +import java.io.*; +import java.util.*; + +public class JY_9342 { + + static boolean isOk; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int T = Integer.parseInt(br.readLine()); + for(int t=0; t> 규칙 + * 0 : 문자열은 {A, B, C, D, E, F} 중 0개 또는 1개로 시작해야 한다. + * 1 : 그 다음에는 A가 하나 또는 그 이상 있어야 한다. + * 2 : 그 다음에는 F가 하나 또는 그 이상 있어야 한다. + * 3 : 그 다음에는 C가 하나 또는 그 이상 있어야 한다. + * 4 : 그 다음에는 {A, B, C, D, E, F} 중 0개 또는 1개가 있으며, 더 이상의 문자는 없어야 한다. + * */ + public static void isGen(String s, int idx, int type) { + if(type == 0) { + if(s.charAt(idx) >= 'A' && s.charAt(idx) <= 'F') { + if(s.charAt(idx) == 'A') isGen(s, idx, 1); // 다음 조건도 A로 시작하므로 인덱스 증가X + else isGen(s, idx+1, 1); + } + } else if(type == 1) { + int next = check(s, idx, 'A'); + if(next != -1) { + isGen(s, next, 2); + } + } else if(type == 2) { + int next = check(s, idx, 'F'); + if(next != -1) { + isGen(s, next, 3); + } + } else if(type == 3) { + int next = check(s, idx, 'C'); + if(next != -1) { + isGen(s, next, 4); + } + } else { + if(idx == s.length()) isOk = true; + else if(idx == s.length()-1 && s.charAt(idx) >= 'A' && s.charAt(idx) <= 'F') { + isOk = true; + } + } + } + public static int check(String s, int idx, char c) { + int i = idx; + while(i < s.length()) { + if(s.charAt(i) != c) break; + i++; + } + if(i > idx) { + return i; + } + return -1; + } + +} From 15694c1bb92bd2ca59b8c39b57e97ecc29dbc907 Mon Sep 17 00:00:00 2001 From: yeong Date: Tue, 29 Oct 2024 15:48:02 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[SQL]=20Game?= =?UTF-8?q?=20Play=20Analysis=20IV=5F241029?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JY_Game_Play_Analysis_IV.sql" | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 "SQL/08\354\243\274\354\260\250/JY_Game_Play_Analysis_IV.sql" diff --git "a/SQL/08\354\243\274\354\260\250/JY_Game_Play_Analysis_IV.sql" "b/SQL/08\354\243\274\354\260\250/JY_Game_Play_Analysis_IV.sql" new file mode 100644 index 00000000..2f91d508 --- /dev/null +++ "b/SQL/08\354\243\274\354\260\250/JY_Game_Play_Analysis_IV.sql" @@ -0,0 +1,7 @@ +-- 550. Game Play Analysis IV +-- https://leetcode.com/problems/game-play-analysis-iv/?envType=study-plan-v2&envId=top-sql-50 +SELECT ROUND(COUNT(DISTINCT A.player_id) / (SELECT COUNT(DISTINCT player_id) FROM activity), 2) AS fraction +FROM activity A +JOIN activity B +on A.player_id = B.player_id +WHERE (A.player_id, A.event_date) in (SELECT player_id, min(event_date) FROM activity group by player_id) AND DATEDIFF(B.event_date, A.event_date) = 1 \ No newline at end of file From 6f838b188a429615e12842a9d1cb1db8648835c7 Mon Sep 17 00:00:00 2001 From: yeong Date: Wed, 30 Oct 2024 14:11:10 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[PG]=2015036?= =?UTF-8?q?9=20=ED=83=9D=EB=B0=B0=20=EB=B0=B0=EB=8B=AC=EA=B3=BC=20?= =?UTF-8?q?=EC=88=98=EA=B1=B0=ED=95=98=EA=B8=B0=5F241030?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Level2/JY_150369.java | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Programmers/Level2/JY_150369.java diff --git a/Programmers/Level2/JY_150369.java b/Programmers/Level2/JY_150369.java new file mode 100644 index 00000000..7cdb216a --- /dev/null +++ b/Programmers/Level2/JY_150369.java @@ -0,0 +1,53 @@ +import java.util.*; + +class Solution { + public long solution(int cap, int n, int[] deliveries, int[] pickups) { + long answer = 0; + + int i = n-1; + while(i >= 0) { + System.out.println("i: "+i); + System.out.println("d: "+Arrays.toString(deliveries)); + System.out.println("p: "+Arrays.toString(pickups)); + + // 배달과 수거 모두 끝난 집은 pass + if(deliveries[i] ==0 && pickups[i] ==0){ + i--; + continue; + } + + // 현재 가장 먼 집위치 + int start = i+1; + + // 배달하기 + int capD = cap; + int d = i; + while(d >= 0) { + if(capD < deliveries[d]) { + deliveries[d] -= capD; + break; + } + capD -= deliveries[d]; + deliveries[d] = 0; + d--; + } + + // 수거하기 + int capP = cap; + int p = i; + while(p >= 0) { + if(capP < pickups[p]) { + pickups[p] -= capP; + break; + } + capP -= pickups[p]; + pickups[p] = 0; + p--; + } + + answer += (start*2); + } + + return answer; + } +} \ No newline at end of file From 26236a1682945834e923bcea35955cceb7341273 Mon Sep 17 00:00:00 2001 From: yeong Date: Wed, 30 Oct 2024 15:52:33 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[BOJ]=202000?= =?UTF-8?q?7=20=EB=96=A1=20=EB=8F=8C=EB=A6=AC=EA=B8=B0=5F241030?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/20001-25000\353\262\210/JY_20007.java" | 125 ++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 "BOJ/20001-25000\353\262\210/JY_20007.java" diff --git "a/BOJ/20001-25000\353\262\210/JY_20007.java" "b/BOJ/20001-25000\353\262\210/JY_20007.java" new file mode 100644 index 00000000..37512909 --- /dev/null +++ "b/BOJ/20001-25000\353\262\210/JY_20007.java" @@ -0,0 +1,125 @@ +package day1030; + +import java.io.*; +import java.util.*; + +public class JY_20007 { + + static long INF = Long.MAX_VALUE; + static int N, M, X, Y; + static List[] g; + static long[] distance; + static class Node implements Comparable { + int n; + long dist; + + public Node(int n, long dist) { + super(); + this.n = n; + this.dist = dist; + } + @Override + public int compareTo(Node other) { + return Long.compare(this.dist, other.dist); + } + + @Override + public String toString() { + return "Node [n=" + n + ", dist=" + dist + "]"; + } + + } + + 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()); + X = Integer.parseInt(st.nextToken()); + Y = Integer.parseInt(st.nextToken()); + + g = new ArrayList[N]; + for(int i=0; i(); + } + + distance = new long[N]; + for(int i=0; i=0; i--) { + if(2*distance[i] > X) { + System.out.println(-1); + return; + } + } + + // 투포인터 이거 왜안되죠??? + // X= 21, distance = [0, 1, 1, 9, 9]이면 최소일수는 2일아닌가요??!! ㅠ0ㅠ +// int s = 0; +// int e = N-1; +// long sum = 2*distance[e]; +// while(s <= e) { +// if(sum + 2*distance[s] <= X) { +// sum += 2*distance[s]; +// s++; +// } else { +// e--; +// ans++; +// sum = 2*distance[e]; +// } +// } + + int ans = 1; + long sum = 0; + for(int i=0; i X) { + ans++; + sum = 2*distance[i]; + } else { + sum += 2*distance[i]; + } + } + + System.out.println(ans); + + } + public static void dijkstra(int start) { + distance[start] = 0; + PriorityQueue pq = new PriorityQueue<>(); + pq.add(new Node(start, 0)); + + while(!pq.isEmpty()) { + Node now = pq.poll(); + + if(distance[now.n] < now.dist) continue; + + for(Node next: g[now.n]) { + long cost = now.dist + next.dist; + if(distance[next.n] > cost) { + distance[next.n] = cost; + pq.add(new Node(next.n, cost)); + } + } + } + } + +} From db7f68e11cfb0b1e04c44fda9d5ef179704dad89 Mon Sep 17 00:00:00 2001 From: yeong Date: Thu, 31 Oct 2024 10:43:40 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[BOJ]=202461?= =?UTF-8?q?=20=EB=8C=80=ED=91=9C=20=EC=84=A0=EC=88=98=5F241031?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000\353\262\210/JY_2461.java" | 60 ++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 "BOJ/1000-5000\353\262\210/JY_2461.java" diff --git "a/BOJ/1000-5000\353\262\210/JY_2461.java" "b/BOJ/1000-5000\353\262\210/JY_2461.java" new file mode 100644 index 00000000..8ce2960c --- /dev/null +++ "b/BOJ/1000-5000\353\262\210/JY_2461.java" @@ -0,0 +1,60 @@ +package day1031; + +import java.io.*; +import java.util.*; + +public class JY_2461 { + + 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 M = Integer.parseInt(st.nextToken()); + + int[][] srr = new int[N][M]; + for(int i=0; i srr[i][j]) { + min = srr[i][j]; + minIdx = i; + } + } + + ans = Math.min(ans, max-min); + n[minIdx]++; + if(n[minIdx] == M) break; + + } + + System.out.println(ans); + + } + + +} From 7d2f318f117d8dfccdf104522398c0196f3e29a5 Mon Sep 17 00:00:00 2001 From: yeong Date: Thu, 31 Oct 2024 13:07:31 +0900 Subject: [PATCH 7/7] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[SQL]=20Imme?= =?UTF-8?q?diate=5FFood=5FDelivery=5FII=5F241031?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JY_Immediate_Food_Delivery_II.sql" | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 "SQL/08\354\243\274\354\260\250/JY_Immediate_Food_Delivery_II.sql" diff --git "a/SQL/08\354\243\274\354\260\250/JY_Immediate_Food_Delivery_II.sql" "b/SQL/08\354\243\274\354\260\250/JY_Immediate_Food_Delivery_II.sql" new file mode 100644 index 00000000..7e3f59bb --- /dev/null +++ "b/SQL/08\354\243\274\354\260\250/JY_Immediate_Food_Delivery_II.sql" @@ -0,0 +1,6 @@ +-- 1174. Immediate Food Delivery II +-- https://leetcode.com/problems/immediate-food-delivery-ii/?envType=study-plan-v2&envId=top-sql-50 +select round(count(customer_id)/(select count(distinct customer_id) from delivery), 4)*100 as immediate_percentage +from delivery +where order_date = customer_pref_delivery_date + and (customer_id, order_date) in (select customer_id, min(order_date) from delivery group by customer_id) \ No newline at end of file