From 4db6900351df076c461d4b058daeebf8fbe8f123 Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Wed, 7 May 2025 10:46:16 +0900 Subject: [PATCH 1/9] =?UTF-8?q?[BOJ]=20#2512.=20=EC=98=88=EC=82=B0=20/=20?= =?UTF-8?q?=EC=8B=A4=EB=B2=842=20/=2040=EB=B6=84=20/=20=EC=8B=A4=ED=8C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...44\200]-#2512-\354\230\210\354\202\260.py" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "minjeong/BinarySearch/2025-05-05-[\353\260\261\354\244\200]-#2512-\354\230\210\354\202\260.py" diff --git "a/minjeong/BinarySearch/2025-05-05-[\353\260\261\354\244\200]-#2512-\354\230\210\354\202\260.py" "b/minjeong/BinarySearch/2025-05-05-[\353\260\261\354\244\200]-#2512-\354\230\210\354\202\260.py" new file mode 100644 index 0000000..2bc218e --- /dev/null +++ "b/minjeong/BinarySearch/2025-05-05-[\353\260\261\354\244\200]-#2512-\354\230\210\354\202\260.py" @@ -0,0 +1,37 @@ +import sys + +input = sys.stdin.readline + +def main(): + N = int(input()) # 지방의 수 + budgets = sorted(map(int, input().split())) # 각 지방의 예상요청 + M = int(input()) # 총 예산 + + # 1. 모든 요청이 배정될 수 있는 경우, 요청 최대값이 정답 + if sum(budgets) <= M: + return budgets[-1] + + # 2. 모든 요청이 배정될 수 없는 경우, 상한액 탐색 + left = 0 + right = budgets[-1] + answer = 0 + + while left <= right: + mid = (left + right) // 2 # 상한액 + total = 0 + for b in budgets: + total += min(b, mid) + + if total <= M: + # 이 상한액으로 배정해도 총액이 허용 범위 이내 → C를 더 높여 볼 수 있음 + answer = mid + left = mid + 1 + else: + # 총액이 초과 → 상한액을 낮춰야 함 + right = mid - 1 + + return answer + + +if __name__ == '__main__': + print(main()) From d63e8e91e8f86d0d308ee4ce00f2e61104b654b1 Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Wed, 7 May 2025 10:48:04 +0900 Subject: [PATCH 2/9] =?UTF-8?q?[PGS]=20=EC=A0=84=ED=99=94=EB=B2=88?= =?UTF-8?q?=ED=98=B8=EB=AA=A9=EB=A1=9D=20/=20Level2=20(Java=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4)=20/=2030=EB=B6=84=20/=20=EC=8B=A4=ED=8C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...210\355\230\270\353\252\251\353\241\235.java" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "minjeong/String/2025-05-07-[PGS]-\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.java" diff --git "a/minjeong/String/2025-05-07-[PGS]-\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.java" "b/minjeong/String/2025-05-07-[PGS]-\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.java" new file mode 100644 index 0000000..a16874f --- /dev/null +++ "b/minjeong/String/2025-05-07-[PGS]-\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.java" @@ -0,0 +1,16 @@ +import java.util.*; + +class Solution { + public boolean solution(String[] phone_book) { + + Arrays.sort(phone_book); // 오름차순 정렬 + + for (int i = 0; i < phone_book.length - 1; i++ ) { + // 만약 다음 값이 현재 값으로 시작한다면, false 반환 + if (phone_book[i+1].startsWith(phone_book[i])) { + return false; + } + } + return true; + } +} \ No newline at end of file From 60a1efb6a55f9dc1612c6f87359ce0d78719468f Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Wed, 7 May 2025 20:21:19 +0900 Subject: [PATCH 3/9] =?UTF-8?q?[PGS]=20=EC=98=AC=EB=B0=94=EB=A5=B8=20?= =?UTF-8?q?=EA=B4=84=ED=98=B8=20/=20=EC=8B=A4=EB=B2=842=20/=2040=EB=B6=84?= =?UTF-8?q?=20/=20=EC=9E=90=EB=B0=94=20=ED=92=80=EC=9D=B4=20/=20=ED=9E=8C?= =?UTF-8?q?=ED=8A=B8,=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\353\260\224\353\245\270\352\264\204\355\230\270(JAVA).java" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "minjeong/Stack, Queue, Priority Queue/2025-05-10-[Programmers]-\354\230\254\353\260\224\353\245\270\352\264\204\355\230\270(JAVA).java" diff --git "a/minjeong/Stack, Queue, Priority Queue/2025-05-10-[Programmers]-\354\230\254\353\260\224\353\245\270\352\264\204\355\230\270(JAVA).java" "b/minjeong/Stack, Queue, Priority Queue/2025-05-10-[Programmers]-\354\230\254\353\260\224\353\245\270\352\264\204\355\230\270(JAVA).java" new file mode 100644 index 0000000..e69de29 From 8612d03b3dc86f7cdc77b6593b121378dad8dbe2 Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Wed, 7 May 2025 20:22:43 +0900 Subject: [PATCH 4/9] =?UTF-8?q?[PGS]=20=EC=98=AC=EB=B0=94=EB=A5=B8=20?= =?UTF-8?q?=EA=B4=84=ED=98=B8=20/=20=EC=8B=A4=EB=B2=842=20/=2040=EB=B6=84?= =?UTF-8?q?=20/=20=EC=9E=90=EB=B0=94=20=ED=92=80=EC=9D=B4=20/=20=ED=9E=8C?= =?UTF-8?q?=ED=8A=B8,=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...45\270\352\264\204\355\230\270(JAVA).java" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git "a/minjeong/Stack, Queue, Priority Queue/2025-05-10-[Programmers]-\354\230\254\353\260\224\353\245\270\352\264\204\355\230\270(JAVA).java" "b/minjeong/Stack, Queue, Priority Queue/2025-05-10-[Programmers]-\354\230\254\353\260\224\353\245\270\352\264\204\355\230\270(JAVA).java" index e69de29..5cd2080 100644 --- "a/minjeong/Stack, Queue, Priority Queue/2025-05-10-[Programmers]-\354\230\254\353\260\224\353\245\270\352\264\204\355\230\270(JAVA).java" +++ "b/minjeong/Stack, Queue, Priority Queue/2025-05-10-[Programmers]-\354\230\254\353\260\224\353\245\270\352\264\204\355\230\270(JAVA).java" @@ -0,0 +1,40 @@ +import java.util.*; + +class Solution { + boolean solution(String s) { + // "(" 이면 stack에 push. ")"이면 stack에서 pop하기 + // stack의 길이가 0이면 true, stack의 길이가 1이상이면 false + + // Stack ArrayList + ArrayList stack = new ArrayList<>(); + + // 문자열을 ArrayList로 변환 + String[] stringParam = s.split(""); + ArrayList list = new ArrayList(Arrays.asList(stringParam)); + + // Stack Push & Pop + for (String str: stringParam){ + // System.out.println(str); + if (str.equals("(")) { + stack.add(0); + // System.out.println("추가 완료"); + } + else { + // 처음부터 ) 가 나올 경우 올바르지 않은 괄호 + if (stack.size() == 0){ + return false; + } + else { + stack.remove(stack.size() - 1); + } + } + } + + // 올바른 괄호가 아닐 경우 + if (stack.size() > 0) { + return false; + } + // 올바른 괄호가 아닌 경우 + return true; + } +} \ No newline at end of file From f16464382192c1d8cb21e96f44625a5fb37c946b Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Mon, 12 May 2025 16:42:06 +0900 Subject: [PATCH 5/9] =?UTF-8?q?[PGS]=20=EA=B8=B0=EB=8A=A5=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C=20/=20Level2=20(Java=20=ED=92=80=EC=9D=B4)=20/=2030?= =?UTF-8?q?=EB=B6=84=20/=20=ED=9E=8C=ED=8A=B8,=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...212\245\352\260\234\353\260\234-java.java" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "minjeong/Stack, Queue, Priority Queue/2025-05-12-[Programmers]-\352\270\260\353\212\245\352\260\234\353\260\234-java.java" diff --git "a/minjeong/Stack, Queue, Priority Queue/2025-05-12-[Programmers]-\352\270\260\353\212\245\352\260\234\353\260\234-java.java" "b/minjeong/Stack, Queue, Priority Queue/2025-05-12-[Programmers]-\352\270\260\353\212\245\352\260\234\353\260\234-java.java" new file mode 100644 index 0000000..4d94b6a --- /dev/null +++ "b/minjeong/Stack, Queue, Priority Queue/2025-05-12-[Programmers]-\352\270\260\353\212\245\352\260\234\353\260\234-java.java" @@ -0,0 +1,29 @@ +import java.util.*; + +class Solution { + public int[] solution(int[] progresses, int[] speeds) { + ArrayList answer = new ArrayList<>(); + ArrayList queue = new ArrayList<>(); + + for (int i=0; i < progresses.length; i++){ + int days = (int) Math.ceil((100.0 - progresses[i]) / speeds[i]); + if (queue.size() > 0 && days > queue.get(0)) { + answer.add(queue.size()); + queue.clear(); + queue.add(days); + + } + else { + queue.add(days); + } + } + answer.add(queue.size()); + + // 배열로 변환 + int[] arr = answer.stream() + .mapToInt(Integer::intValue) + .toArray(); + + return arr; + } +} \ No newline at end of file From be745b2615a70154ae2eaa4466feb602610fbcec Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Mon, 12 May 2025 19:38:12 +0900 Subject: [PATCH 6/9] =?UTF-8?q?[PGS]=20=ED=94=84=EB=A1=9C=EC=84=B8?= =?UTF-8?q?=EC=8A=A4=20/=20Level2=20(Java=20=ED=92=80=EC=9D=B4)=20/=2052?= =?UTF-8?q?=EB=B6=84=20/=20=EC=8B=A4=ED=8C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...241\234\354\204\270\354\212\244-java.java" | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 "minjeong/Stack, Queue, Priority Queue/2025-05-12-[Programmers]-\355\224\204\353\241\234\354\204\270\354\212\244-java.java" diff --git "a/minjeong/Stack, Queue, Priority Queue/2025-05-12-[Programmers]-\355\224\204\353\241\234\354\204\270\354\212\244-java.java" "b/minjeong/Stack, Queue, Priority Queue/2025-05-12-[Programmers]-\355\224\204\353\241\234\354\204\270\354\212\244-java.java" new file mode 100644 index 0000000..512deae --- /dev/null +++ "b/minjeong/Stack, Queue, Priority Queue/2025-05-12-[Programmers]-\355\224\204\353\241\234\354\204\270\354\212\244-java.java" @@ -0,0 +1,51 @@ +import java.util.*; + +class Solution { + public int solution(int[] priorities, int location) { + // 1) 작업 큐: 인덱스(idx)와 우선순위(priority)를 함께 보관 + Queue queue = new LinkedList<>(); + + // 2) 우선순위 큐: 남아있는 작업 중 가장 높은 우선순위를 꺼내기 위함 + PriorityQueue pq = new PriorityQueue<>(Collections.reverseOrder()); + + for (int i = 0 ; i < priorities.length; i++) { + queue.offer(new DTO(i, priorities[i])); + pq.offer(priorities[i]); + } + + // System.out.println(queue); + // System.out.println(pq); + + int count = 0; // 실행된 작업 수 + + while(!queue.isEmpty()) { + DTO cur = queue.poll(); // 현재 작업 꺼냄 + + // 현재 작업 우선순위가 남은 작업의 최고 우선순위와 같다면 + if(cur.priority == pq.peek()) { + count++; + pq.poll(); // 우선순위 큐에서 제거 + // 내가 찾던 작업이라면 실행 순서 반환 + if (cur.idx == location) { + return count; + } + } + else { + // 우선순위가 더 높은 작업이 남아있다면 뒤로 재삽입 + queue.offer(cur); + } + } + return count; + } + + // 인덱스 + 우선순위를 함께 보관할 DTO + static class DTO { + int idx; + int priority; + DTO(int idx, int priority) { + this.idx = idx; + this.priority = priority; + // System.out.println("idx: "+idx+" priority: "+priority); + } + } +} \ No newline at end of file From 8b08e1eea8bc12c6a33a6a5001a367db9874b7a9 Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Tue, 13 May 2025 12:50:21 +0900 Subject: [PATCH 7/9] =?UTF-8?q?[BOJ]=20#1283.=20=EB=8B=A8=EC=B6=95?= =?UTF-8?q?=ED=82=A4=20=EC=A7=80=EC=A0=95=20/=20=EC=8B=A4=EB=B2=841=20/=20?= =?UTF-8?q?40=EB=B6=84=20/=20=ED=9E=8C=ED=8A=B8,=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...25\355\202\244\354\247\200\354\240\225.py" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "minjeong/Simulation/2025-05-12-[\353\260\261\354\244\200]-#1283-\353\213\250\354\266\225\355\202\244\354\247\200\354\240\225.py" diff --git "a/minjeong/Simulation/2025-05-12-[\353\260\261\354\244\200]-#1283-\353\213\250\354\266\225\355\202\244\354\247\200\354\240\225.py" "b/minjeong/Simulation/2025-05-12-[\353\260\261\354\244\200]-#1283-\353\213\250\354\266\225\355\202\244\354\247\200\354\240\225.py" new file mode 100644 index 0000000..4797401 --- /dev/null +++ "b/minjeong/Simulation/2025-05-12-[\353\260\261\354\244\200]-#1283-\353\213\250\354\266\225\355\202\244\354\247\200\354\240\225.py" @@ -0,0 +1,32 @@ +import sys + +input = sys.stdin.readline + + +def setOptions(option): + # 1. 각 단어의 첫 글자 우선 확인 + for i in range(len(option)): + if option[i][0].upper() not in shortcut_key: + shortcut_key.add(option[i][0].upper()) + option[i] = f"[{option[i][0]}]{option[i][1:]}" + return option + + # 2. 전체 단어의 모든 글자 중 아직 등록되지 않은 글자 탐색 + for i in range(len(option)): + for j in range(len(option[i])): + if option[i][j].upper() not in shortcut_key: + shortcut_key.add(option[i][j].upper()) + option[i] = f"{option[i][:j]}[{option[i][j]}]{option[i][j + 1:]}" + return option + + # 3. 지정할 수 있는 단축키가 없는 경우 + return option + + +N = int(input()) +shortcut_key = set() + +for _ in range(N): + option = input().split() + result = setOptions(option) + print(' '.join(result)) From 2ac22bc16bc70f70712c6ce193b593d6275dfb12 Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Fri, 16 May 2025 11:49:55 +0900 Subject: [PATCH 8/9] =?UTF-8?q?[BOJ]=20#2564.=20=EA=B2=BD=EB=B9=84?= =?UTF-8?q?=EC=9B=90=20/=20=EC=8B=A4=EB=B2=841=20/=2060=EB=B6=84=20/=20?= =?UTF-8?q?=EC=8B=A4=ED=8C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4-\352\262\275\353\271\204\354\233\220.py" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "minjeong/Simulation/2025-05-16-[\353\260\261\354\244\200]-#2564-\352\262\275\353\271\204\354\233\220.py" diff --git "a/minjeong/Simulation/2025-05-16-[\353\260\261\354\244\200]-#2564-\352\262\275\353\271\204\354\233\220.py" "b/minjeong/Simulation/2025-05-16-[\353\260\261\354\244\200]-#2564-\352\262\275\353\271\204\354\233\220.py" new file mode 100644 index 0000000..1b7b02c --- /dev/null +++ "b/minjeong/Simulation/2025-05-16-[\353\260\261\354\244\200]-#2564-\352\262\275\353\271\204\354\233\220.py" @@ -0,0 +1,44 @@ +import sys +input = sys.stdin.readline + +# 1. 입력받기 +w, h = map(int, input().split()) # 가로, 세로 +store_cnt = int(input()) # 상점의 개수 + +# 2. 둘레 계산 +perimeter = 2 * (w + h) + +# 3. (방향, 거리) -> 1차원 위치로 변환 함수 +def to_pos(dir, dist): + if dir == 1: # 북 + return dist + if dir == 2: # 남 + return w + h + (w - dist) + if dir == 3: # 서 + return 2*w + h + (h - dist) + if dir == 4: # 동 + return w + dist + + +# 4. 모든 상점의 위치를 1차원 조표로 변환해서 리스트에 모으기 +store_loc = [] # 상점의 위치 +for _ in range(store_cnt): + d, dist = map(int, input().split()) + store_loc.append(to_pos(d, dist)) + +# 5. 경비원 위치도 똑같이 변환 +gd, gdist = map(int, input().split()) +guard_pos = to_pos(gd, gdist) + +# print(f"store: {store_loc}") +# print(f"guard: {guard_pos}") + +# 6. 각 상점까지 최단 거리 구해서 합산 +total = 0 +for store in store_loc: + diff = abs(store - guard_pos) + # 시계방향 <-> 반시계방향 중 짧은 거리 선택 + total += min(diff, perimeter - diff) + +# 7. 결과 출력 +print(total) \ No newline at end of file From 18f9e8c090ddc5a1fe4796f5426dfda97283a4cd Mon Sep 17 00:00:00 2001 From: Minjeong Kim <101111603+Mingguriguri@users.noreply.github.com> Date: Wed, 14 May 2025 12:32:56 +0900 Subject: [PATCH 9/9] =?UTF-8?q?[PGS]=20=EA=B0=99=EC=9D=80=20=EC=88=AB?= =?UTF-8?q?=EC=9E=90=EB=8A=94=20=EC=8B=AB=EC=96=B4=20/=20Level=201=20/=201?= =?UTF-8?q?5=EB=B6=84=20/=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...12\224\354\213\253\354\226\264(java).java" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "minjeong/Stack, Queue, Priority Queue/2025-05-14-[PGS]-\352\260\231\354\235\200\354\210\253\354\236\220\353\212\224\354\213\253\354\226\264(java).java" diff --git "a/minjeong/Stack, Queue, Priority Queue/2025-05-14-[PGS]-\352\260\231\354\235\200\354\210\253\354\236\220\353\212\224\354\213\253\354\226\264(java).java" "b/minjeong/Stack, Queue, Priority Queue/2025-05-14-[PGS]-\352\260\231\354\235\200\354\210\253\354\236\220\353\212\224\354\213\253\354\226\264(java).java" new file mode 100644 index 0000000..a95c470 --- /dev/null +++ "b/minjeong/Stack, Queue, Priority Queue/2025-05-14-[PGS]-\352\260\231\354\235\200\354\210\253\354\236\220\353\212\224\354\213\253\354\226\264(java).java" @@ -0,0 +1,25 @@ +import java.util.*; + +public class Solution { + public int[] solution(int []arr) { + ArrayList answer = new ArrayList<>(); + + // 1. 첫 번째 값은 무조건 추가 + answer.add(arr[0]); + + // 2. 두 번째 값부터 순차적으로 확인 + for (int i = 1; i < arr.length; i++) { + // 바로 이전 값과 다르면 추가 + if (answer.get(answer.size()-1) != arr[i]) { + answer.add(arr[i]); + } + } + + // 3. ArrayList → int[] 변환 + int[] answer2 = new int[answer.size()]; + for (int i = 0; i < answer.size(); i++){ + answer2[i] = answer.get(i); + } + return answer2; + } +} \ No newline at end of file