From 2d558547154f83270fd3e5f7edc2290652a9c1b8 Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Tue, 30 Sep 2025 11:45:03 +0900 Subject: [PATCH 1/5] =?UTF-8?q?Solved:=201302=20=EB=B2=A0=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=85=80=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...212\244\355\212\270\354\205\200\353\237\254.py" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "INSEA-99/week04/1302_\353\262\240\354\212\244\355\212\270\354\205\200\353\237\254.py" diff --git "a/INSEA-99/week04/1302_\353\262\240\354\212\244\355\212\270\354\205\200\353\237\254.py" "b/INSEA-99/week04/1302_\353\262\240\354\212\244\355\212\270\354\205\200\353\237\254.py" new file mode 100644 index 0000000..c4b5bba --- /dev/null +++ "b/INSEA-99/week04/1302_\353\262\240\354\212\244\355\212\270\354\205\200\353\237\254.py" @@ -0,0 +1,14 @@ +# 시간(ms) : 104 +# 공간(KB) : 110064 +# +# 공유 : +# - counter는 내부적으로 dictionary로 구현됨 +# - counter['a']는 dict에서 'a'의 개수를 반환 + +import sys +from collections import Counter +input = sys.stdin.readline + +books = [input().strip() for _ in range(int(input().strip()))] +counter = Counter(books) +print(sorted(counter, key=lambda x : (-counter[x], x), reverse=True)[-1]) \ No newline at end of file From b284b29a3986fd5eb3ad9b3093bfbe49dd642815 Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Tue, 30 Sep 2025 11:45:27 +0900 Subject: [PATCH 2/5] =?UTF-8?q?Solved:=201431=20=EC=8B=9C=EB=A6=AC?= =?UTF-8?q?=EC=96=BC=20=EB=B2=88=ED=98=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\226\274_\353\262\210\355\230\270.py" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "INSEA-99/week04/1431_\354\213\234\353\246\254\354\226\274_\353\262\210\355\230\270.py" diff --git "a/INSEA-99/week04/1431_\354\213\234\353\246\254\354\226\274_\353\262\210\355\230\270.py" "b/INSEA-99/week04/1431_\354\213\234\353\246\254\354\226\274_\353\262\210\355\230\270.py" new file mode 100644 index 0000000..a1a7a4b --- /dev/null +++ "b/INSEA-99/week04/1431_\354\213\234\353\246\254\354\226\274_\353\262\210\355\230\270.py" @@ -0,0 +1,25 @@ +# pypy3 +# 시간(ms) : 92 +# 공간(KB) : 109544 + +import sys +input = sys.stdin.readline + + +def sort_serial_nums(serial_num) : + """_summary_ + + Args: + serial_num(string) : 정렬 대상 원소 + + Returns: + 정렬 기준 반환 + 1. (오름) 길이 + 2. (오름) 원소 내 숫자 합 + 3. (오름) 사전순 + """ + sum_digits = sum(int(ch) for ch in serial_num if ch.isdigit()) + return (len(serial_num), sum_digits, serial_num) + +serial_nums = [input().strip() for _ in range(int(input().strip()))] +print(*sorted(serial_nums, key=sort_serial_nums), sep='\n') \ No newline at end of file From 3aa9213115a1916d30b608ca2f260956de03ca1a Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Tue, 30 Sep 2025 11:48:32 +0900 Subject: [PATCH 3/5] =?UTF-8?q?Solved:=201431=20=EC=8B=9C=EB=A6=AC?= =?UTF-8?q?=EC=96=BC=20=EB=B2=88=ED=98=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\246\254\354\226\274_\353\262\210\355\230\270.py" | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git "a/INSEA-99/week04/1431_\354\213\234\353\246\254\354\226\274_\353\262\210\355\230\270.py" "b/INSEA-99/week04/1431_\354\213\234\353\246\254\354\226\274_\353\262\210\355\230\270.py" index a1a7a4b..c9724fa 100644 --- "a/INSEA-99/week04/1431_\354\213\234\353\246\254\354\226\274_\353\262\210\355\230\270.py" +++ "b/INSEA-99/week04/1431_\354\213\234\353\246\254\354\226\274_\353\262\210\355\230\270.py" @@ -1,6 +1,17 @@ # pypy3 # 시간(ms) : 92 # 공간(KB) : 109544 +# +# Python3 +# 시간(ms) : 40 +# 공간(KB) : 32412 +# +# 공유 : +# 빠른 입출력 + 내장 함수 (정렬, math 등) +# → Python3 추천 + +# 루프 많고 연산-heavy (단순 반복, 시뮬레이션) +# → PyPy3 추천 import sys input = sys.stdin.readline From d16e09f6be75821b57dd0b551e258b9627921d9d Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Tue, 30 Sep 2025 12:34:41 +0900 Subject: [PATCH 4/5] =?UTF-8?q?Solved:=201072=20=EA=B2=8C=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week04/1072_\352\262\214\354\236\204.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "INSEA-99/week04/1072_\352\262\214\354\236\204.py" diff --git "a/INSEA-99/week04/1072_\352\262\214\354\236\204.py" "b/INSEA-99/week04/1072_\352\262\214\354\236\204.py" new file mode 100644 index 0000000..5e41c0b --- /dev/null +++ "b/INSEA-99/week04/1072_\352\262\214\354\236\204.py" @@ -0,0 +1,19 @@ +# pypy3 +# 시간(ms) : 88 +# 공간(KB) : 108384 + +import sys +input = sys.stdin.readline +MAX = 1000000000 + +def bs(left, right, x, y, z) : + mid = (left + right) // 2 # 추가 게임 횟수 + while (left <= right) : + if ((y + mid) * 100 // (x + mid) <= z) : left = mid + 1 # 초기승률이 추가게임승률보다 크거나 같은 경우 업데이트 + else : right = mid - 1 # 초기승률이 추가게임승률보다 작은 경우 업데이트 + mid = (left + right) // 2 + return mid + 1 + +x, y = map(int, input().strip().split()) # 입력 받기 +z = y * 100 // x +print(-1 if z >= 99 else bs(0, MAX, x, y, z)) \ No newline at end of file From 478e17152a94514081f461e335a8593de5cd13de Mon Sep 17 00:00:00 2001 From: INSEA-99 Date: Tue, 30 Sep 2025 12:41:58 +0900 Subject: [PATCH 5/5] =?UTF-8?q?Solved:=202805=20=EB=82=98=EB=AC=B4=20?= =?UTF-8?q?=EC=9E=90=EB=A5=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4_\354\236\220\353\245\264\352\270\260.py" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "INSEA-99/week04/2805_\353\202\230\353\254\264_\354\236\220\353\245\264\352\270\260.py" diff --git "a/INSEA-99/week04/2805_\353\202\230\353\254\264_\354\236\220\353\245\264\352\270\260.py" "b/INSEA-99/week04/2805_\353\202\230\353\254\264_\354\236\220\353\245\264\352\270\260.py" new file mode 100644 index 0000000..367f454 --- /dev/null +++ "b/INSEA-99/week04/2805_\353\202\230\353\254\264_\354\236\220\353\245\264\352\270\260.py" @@ -0,0 +1,30 @@ +# pypy3 +# 시간(ms) : 460 +# 공간(KB) : 258500 + +import sys +input = sys.stdin.readline + +def count(h): # h미터로 자르고 남은 나무 길이 합 구하기 + n = 0 + for tree in trees: + if tree-h > 0: + n+= tree-h + return n + +def bs(N): + left = 0 + right = trees[-1] + mid = right // 2 + + while left <= right: + m = count(mid) + if m < N: right = mid-1 # 가져가야하는 길이보다 적은 경우 + elif m >= N: left = mid+1 # 가져가야하는 길이보다 많거나 같은 경우 (최대 H를 구해야하므로 중지하지 않고 진행) + mid = (left+right)//2 + return mid + + +k, N = map(int, input().strip().split()) +trees = sorted(list(map(int, input().strip().split()))) +print(bs(N)) \ No newline at end of file