From b27405ce5882dbc7bf7e2475316ccc70a0033e58 Mon Sep 17 00:00:00 2001 From: baexxbin Date: 2024年12月30日 15:04:49 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[CT]=20?= =?UTF-8?q?=EB=B3=B4=EB=8F=84=EB=B8=94=EB=9F=AD=5F241230?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...353円217円204円353円270円224円353円237円255円.java" | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 "CodeTree/2017-2018353円205円204円/SB_353円263円264円353円217円204円353円270円224円353円237円255円.java" diff --git "a/CodeTree/2017-2018353円205円204円/SB_353円263円264円353円217円204円353円270円224円353円237円255円.java" "b/CodeTree/2017-2018353円205円204円/SB_353円263円264円353円217円204円353円270円224円353円237円255円.java" new file mode 100644 index 00000000..2dcf89b2 --- /dev/null +++ "b/CodeTree/2017-2018353円205円204円/SB_353円263円264円353円217円204円353円270円224円353円237円255円.java" @@ -0,0 +1,62 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/* +* 오름차순: 세어온 개수가 L이상이고 다음 높이랑 1차이나면 가능 +* 내림차순: 이전값 pre, 이후 세는 개수가 L이상이고 pre랑 높이 1차이나면 가능 +* */ +public class SB_보도블럭 { + static int N, L; + static int[][] board; + static int ans = 0; + + private static boolean canPass(int[] line) { + boolean[] used = new boolean[N]; + for (int i = 0; i < N - 1; i++) { + if (line[i]==line[i+1]) continue; // 같은 높이 + if (line[i+1]-line[i]==1) { // 오름차순 + for (int j = 0; j < L; j++) { // 자기자신부터 경사로 설치 됨 + if (i-j < 0 || line[i] != line[i-j] || used[i-j]) return false; + used[i-j] = true; + } + } else if (line[i+1]-line[i]==-1) { // 내림차순 + for (int j = 1; j <= L; j++) { // 자기 앞에부터 경사로 설치 + if (i+j>=N || line[i+1] != line[i+j] || used[i+j]) return false; + used[i+j] = true; + } + } else return false; // 높이차로 경사로 설치 불가 + } + return true; + } + 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()); + + board = new int[N][N]; + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + for (int j = 0; j < N; j++) { + board[i][j] = Integer.parseInt(st.nextToken()); + } + } + + for (int[] row : board){ // 가로 확인 + if (canPass(row)) ans++; + } + + for (int j = 0; j < N; j++) { // 세로 확인 + int[] col = new int[N]; + for (int i = 0; i < N; i++) { + col[i] = board[i][j]; + } + if (canPass(col)) ans++; + } + + System.out.println(ans); + } +} From 12a6f6d2b6ab598b958d21eb125c34392fff898c Mon Sep 17 00:00:00 2001 From: baexxbin Date: Wed, 1 Jan 2025 18:47:51 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=202332?= =?UTF-8?q?6=20=ED=99=8D=EC=9D=B5=20=ED=88=AC=EC=96=B4=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=5F250101?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/20001-25000353円262円210円/SB_23326.java" | 53 +++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 "BOJ/20001-25000353円262円210円/SB_23326.java" diff --git "a/BOJ/20001-25000353円262円210円/SB_23326.java" "b/BOJ/20001-25000353円262円210円/SB_23326.java" new file mode 100644 index 00000000..5d18494a --- /dev/null +++ "b/BOJ/20001-25000353円262円210円/SB_23326.java" @@ -0,0 +1,53 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; +import java.util.TreeSet; + +public class SB_23326 { + static int N, Q; + static TreeSet place = new TreeSet(); + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + StringBuilder sb = new StringBuilder(); + + N = Integer.parseInt(st.nextToken()); + Q = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + for (int i = 0; i < N; i++) { + if (Integer.parseInt(st.nextToken())==1) place.add(i); + } + + int cur = 0; + while (Q--> 0) { + st = new StringTokenizer(br.readLine()); + int cmd = Integer.parseInt(st.nextToken()); + switch (cmd) { + case 1: + int p = Integer.parseInt(st.nextToken()) - 1; + if (place.contains(p)) place.remove(p); + else place.add(p); + break; + case 2: + int val = Integer.parseInt(st.nextToken()); + cur = (cur + val) % N; + break; + case 3: + if (place.isEmpty()) sb.append(-1).append('\n'); + else if (place.contains(cur)) sb.append(0).append('\n'); + else { + Integer right = place.higher(cur); + if (right != null) sb.append(right - cur).append('\n'); + else { + Integer left = place.first(); + sb.append(N - cur + left).append('\n'); + } + } + break; + } + } + System.out.println(sb); + } +} From ce239c15f71b2b877af5f029c1d199ef9423e731 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Wed, 1 Jan 2025 20:58:19 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[SQL]=20Conf?= =?UTF-8?q?irmation=20Rate=5F250101?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "SQL/16354円243円274円354円260円250円/SB_Confirmation Rate.sql" | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 "SQL/16354円243円274円354円260円250円/SB_Confirmation Rate.sql" diff --git "a/SQL/16354円243円274円354円260円250円/SB_Confirmation Rate.sql" "b/SQL/16354円243円274円354円260円250円/SB_Confirmation Rate.sql" new file mode 100644 index 00000000..0cf3c26a --- /dev/null +++ "b/SQL/16354円243円274円354円260円250円/SB_Confirmation Rate.sql" @@ -0,0 +1,8 @@ +# Write your MySQL query statement below +# 사용자의 확인율은 '확인'된 메시지의 수를 요청된 확인 메시지의 총 수로 나눈 값입니다. 확인 메시지를 요청하지 않은 사용자의 확인율은 0입니다. 확인율을 소수점 두 자리로 반올림합니다. + +SELECT s.user_id, + ROUND(IFNULL(AVG(c.action="confirmed"),0),2) AS confirmation_rate +FROM Signups s +LEFT JOIN Confirmations c ON s.user_id = c.user_id +GROUP BY s.user_id \ No newline at end of file From d2f98fd100c1667871f53b50f2de5a5d19162967 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Thu, 2 Jan 2025 10:12:37 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=202000?= =?UTF-8?q?2=20=EC=82=AC=EA=B3=BC=EB=82=98=EB=AC=B4=5F250102?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/20001-25000353円262円210円/SB_20002.java" | 40 +++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "BOJ/20001-25000353円262円210円/SB_20002.java" diff --git "a/BOJ/20001-25000353円262円210円/SB_20002.java" "b/BOJ/20001-25000353円262円210円/SB_20002.java" new file mode 100644 index 00000000..5d24ee32 --- /dev/null +++ "b/BOJ/20001-25000353円262円210円/SB_20002.java" @@ -0,0 +1,40 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class SB_20002 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + int N = Integer.parseInt(br.readLine()); + int[][] board = new int[N][N]; + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + for (int j = 0; j < N; j++) { + board[i][j] = Integer.parseInt(st.nextToken()); + } + } + + int[][] dp = new int[N + 1][N + 1]; + for (int i = 1; i <= N; i++) { // 누적합 + for (int j = 1; j <= N; j++) { + dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + board[i - 1][j - 1]; + } + } + + int mx = Integer.MIN_VALUE; + for (int k = 0; k < N; k++) { + for (int i = 1; i < N - k + 1; i++) { + for (int j = 1; j < N - k + 1; j++) { + int box = dp[i+k][j+k]-dp[i-1][j+k]-dp[i+k][j-1]+dp[i-1][j-1]; + mx = Math.max(mx, box); + } + } + } + + System.out.println(mx); + + } +} From 1b62c1d03f31ea53f77b8e9b7ffebf43c9d45b23 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Thu, 2 Jan 2025 13:58:25 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[PG]=2013170?= =?UTF-8?q?3=202=EC=B0=A8=EC=9B=90=20=EB=8F=99=EC=A0=84=20=EB=92=A4?= =?UTF-8?q?=EC=A7=91=EA=B8=B0=5F250102?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Level3/SB_131703.java | 68 +++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Programmers/Level3/SB_131703.java diff --git a/Programmers/Level3/SB_131703.java b/Programmers/Level3/SB_131703.java new file mode 100644 index 00000000..4eb109f8 --- /dev/null +++ b/Programmers/Level3/SB_131703.java @@ -0,0 +1,68 @@ +public class SB_131703 { + static int N, M; + static int[][] tg; + + private static boolean isSame(int[][] board){ + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + if (board[i][j] != tg[i][j]) return false; + } + } + return true; + } + + private static void flipRow(int[][] board, int r) { // 행 뒤집기 + for (int c = 0; c < M; c++) { + board[r][c] ^= 1; + } + } + private static void flipCol(int[][] board, int c) { // 열 뒤집기 + for (int r = 0; r < N; r++) { + board[r][c] ^= 1; + } + } + + private static int[][] copy(int[][] origin) { + int[][] board = new int[N][M]; + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + board[i][j] = origin[i][j]; + } + } + return board; + } + public static int solution(int[][] beginning, int[][] target) { + N = target.length; + M = target[0].length; + tg = copy(target); + + int mn = Integer.MAX_VALUE; + + for (int rowMask = 0; rowMask < (1 << N); rowMask++) { // 모든 행의 뒤집기 조합 + for (int colMask = 0; colMask < (1 << M); colMask++) { // 모든 열의 뒤집기 조합 + int[][] tmp = copy(beginning); + int flip = 0; + + // 뒤집기에 해당하는 행 찾기 + for (int r = 0; r < N; r++) { + if ((rowMask & (1< Date: Fri, 3 Jan 2025 15:54:46 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=202258?= =?UTF-8?q?=20=EC=A0=95=EC=9C=A1=EC=A0=90=5F250103?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/SB_2258.java" | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/SB_2258.java" diff --git "a/BOJ/1000-5000353円262円210円/SB_2258.java" "b/BOJ/1000-5000353円262円210円/SB_2258.java" new file mode 100644 index 00000000..f92e4fd9 --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/SB_2258.java" @@ -0,0 +1,52 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class SB_2258 { + static int N, M; + static int[][] dp; + 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()); + + dp = new int[N][2]; + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + dp[i][0] = Integer.parseInt(st.nextToken()); // 무게 + dp[i][1] = Integer.parseInt(st.nextToken()); // 가격 + } + + // 가격 오름차순, 무게 내림차순 + Arrays.sort(dp, (o1, o2) -> { + if (o1[1] != o2[1]) return o1[1] - o2[1]; + return o2[0] - o1[0]; // 가격이 같을땐 무게 기준 내림차순 + }); + + + int total = 0; + int price = 0; + int mn = Integer.MAX_VALUE; + boolean flag = false; + + for (int i = 0; i < N; i++) { + total += dp[i][0]; // 무게 계속 누적 됨 + + if (i> 0 && dp[i-1][1] == dp[i][1]) // 같은 가격의 고기는 돈 지불 + price += dp[i][1]; + else price = dp[i][1]; // 다른 가격이면, 이 가격으로 지금까지 고기 다 살 수 있음(가격 오름차순 정렬) + + if (total>= M){ + flag = true; + mn = Math.min(mn, price); // 동일한 가격이 누적됐을때, 새로운 값이 더 쌀 수 있음 + } + } + + System.out.println(flag ? mn : -1); + + } +} From ff5c5e361c1986aa82ca9db98bd45136332fe3e2 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Fri, 3 Jan 2025 17:52:38 +0900 Subject: [PATCH 7/7] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[SQL]=20Nth?= =?UTF-8?q?=20Highest=20Salary=5F250103?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SB_Nth Highest Salary.sql" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "SQL/16354円243円274円354円260円250円/SB_Nth Highest Salary.sql" diff --git "a/SQL/16354円243円274円354円260円250円/SB_Nth Highest Salary.sql" "b/SQL/16354円243円274円354円260円250円/SB_Nth Highest Salary.sql" new file mode 100644 index 00000000..a1a45793 --- /dev/null +++ "b/SQL/16354円243円274円354円260円250円/SB_Nth Highest Salary.sql" @@ -0,0 +1,13 @@ +CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT +BEGIN +SET N = N-1; + RETURN ( + # Write your MySQL query statement below. + # Employee 테이블에서 n번째로 큰 급여를 반환하는 query를 작성 + # 만약에 n번째로 큰 급여 정보가 없다면, NULL을 반환 + SELECT DISTINCT salary + FROM Employee + ORDER BY salary DESC + LIMIT 1 OFFSET N + ); +END \ No newline at end of file

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