Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

40-pknujsp #168

Merged
merged 5 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ์ž๋ฌผ์‡ ์˜ ์ค‘๊ฐ„ ๋ถ€๋ถ„์ด ๋ชจ๋‘ 1์ธ์ง€ ํ™•์ธ
def is_valid(new_lock):
length = len(new_lock) // 3

for r in range(length, length * 2):
for c in range(length, length * 2):
if new_lock[r][c] != 1:
return False

return True

def solution(key, lock):
n = len(lock)
k = len(key)
new_lock = [[0] * (n * 3) for _ in range(n * 3)]

for r in range(n):
for c in range(n):
new_lock[r + n][c + n] = lock[r][c]

for _ in range(4):
rev_key = key[::-1]
key = []
for c in range(k):
row = []
for r in range(k):
row.append(rev_key[r][c])
key.append(row)

"""
์—ด์‡ ๋ฅผ ๋Œ๋ฆฌ๋Š” ๋กœ์ง์€ ํ•œ ์ค„๋กœ๋„ ๊ตฌํ˜„๊ฐ€๋Šฅ ํ•ฉ๋‹ˆ๋‹ค
key = [row for row in zip(*reversed(key))]
"""

for r in range(n * 2):
for c in range(n * 2):
# ์ž๋ฌผ์‡ ์— ์—ด์‡ ๋ฅผ ๋ผ์šด๋‹ค
for i in range(k):
for j in range(k):
new_lock[r + i][c + j] += key[i][j]

# ์ž๋ฌผ์‡ ์— ์—ด์‡ ๊ฐ€ ๋”ฑ ๋“ค์–ด๊ฐ”๋Š”์ง€ ํ™•์ธ
if is_valid(new_lock):
return True

# ์ž๋ฌผ์‡ ์—์„œ ์—ด์‡ ๋ฅผ ๋นผ์„œ ๋ณต๊ตฌ์‹œํ‚จ๋‹ค
for i in range(k):
for j in range(k):
new_lock[r + i][c + j] -= key[i][j]
return False
48 changes: 26 additions & 22 deletions pknujsp/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
## โœ๏ธ ๊ธฐ๋ก

| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
| :----: | :--------: | :-------------: | :-----------------------------------------------------------------------------------------------: | :--------------------------------------------------------: |
| 1์ฐจ์‹œ | 2023.10.07 | BRUTE_FORCE | [BOJ_1107](https://www.acmicpc.net/problem/1107) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/2) |
| 2์ฐจ์‹œ | 2023.10.09 | BRUTE_FORCE | [์—ฐ์† ๋ถ€๋ถ„ ์ˆ˜์—ด ํ•ฉ์˜ ๊ฐœ์ˆ˜](https://school.programmers.co.kr/learn/courses/30/lessons/131701) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/5) |
| 3์ฐจ์‹œ | 2023.10.11 | SORT | [์ตœ์†Ÿ๊ฐ’ ๋งŒ๋“ค๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12941?language=python3) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/8) |
| 4์ฐจ์‹œ | 2023.10.13 | SORT | [ํŠœํ”Œ](https://school.programmers.co.kr/learn/courses/30/lessons/64065) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/9) |
| 5์ฐจ์‹œ | 2023.10.15 | ๊ตฌํ˜„ | [๊ด„ํ˜ธ ๋ณ€ํ™˜](https://school.programmers.co.kr/learn/courses/30/lessons/60058) | [#13](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/13) |
| 6์ฐจ์‹œ | 2023.10.17 | ํƒ์ƒ‰ | [์ฟผ๋“œ์••์ถ• ํ›„ ๊ฐœ์ˆ˜ ์„ธ๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/68936) | [#16](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/16) |
| 7์ฐจ์‹œ | 2023.10.19 | ํƒ์ƒ‰ | [๋ฌด์ธ๋„ ์—ฌํ–‰](https://school.programmers.co.kr/learn/courses/30/lessons/154540) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/20) |
| 8์ฐจ์‹œ | 2023.10.21 | ํƒ์ƒ‰ | [๊ฑฐ๋ฆฌ๋‘๊ธฐ ํ™•์ธํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/81302) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/22) |
| 9์ฐจ์‹œ | 2023.10.23 | ๋งต | [์Šคํ‚ฌ ํŠธ๋ฆฌ](https://school.programmers.co.kr/learn/courses/30/lessons/49993) | [#25](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/25) |
| 10์ฐจ์‹œ | 2023.10.25 | ๊ตฌํ˜„ | [์ˆ˜์‹ ์ตœ๋Œ€ํ™”](https://school.programmers.co.kr/learn/courses/30/lessons/67257) | [#28](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/28) |
| 11์ฐจ์‹œ | 2023.10.27 | ๋ฆฌ์ŠคํŠธ | [์˜์–ด ๋๋ง์ž‡๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12981) | [#30](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/30) |
| 12์ฐจ์‹œ | 2023.10.30 | ํ | [์ด์ค‘์šฐ์„ ์ˆœ์œ„ํ](https://school.programmers.co.kr/learn/courses/30/lessons/42628) | [#36](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/36) |
| 13์ฐจ์‹œ | 2023.11.01 | DP | [๋“ฑ๊ตฃ๊ธธ](https://school.programmers.co.kr/learn/courses/30/lessons/42898) | [#39](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/39) |
| 14์ฐจ์‹œ | 2023.11.03 | ๋งต | [์‹œ์†Œ ์ง๊ฟ](https://school.programmers.co.kr/learn/courses/30/lessons/152996) | [#43](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/43) |
| 15์ฐจ์‹œ | 2023.11.05 | ์ˆ˜ํ•™ | [์˜ˆ์ƒ ๋Œ€์ง„ํ‘œ](https://school.programmers.co.kr/learn/courses/30/lessons/12985) | [#47](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/47) |
| 16์ฐจ์‹œ | 2023.11.08 | ์ˆ˜ํ•™ | [์ˆซ์ž ๋ณ€ํ™˜ํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/154538) | [#51](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/51) |
| 17์ฐจ์‹œ | 2023.11.10 | ์Šคํƒ | [์ง์ง€์–ด ์ œ๊ฑฐํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12973) | [#54](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/54) |
| 18์ฐจ์‹œ | 2023.11.13 | ๊ตฌํ˜„ | [ํ‚คํŒจ๋“œ ๋ˆ„๋ฅด๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/67256) | [#60](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/60) |
| 19์ฐจ์‹œ | 2023.11.17 | ๊ตฌํ˜„ | [์‹คํŒจ์œจ](https://school.programmers.co.kr/learn/courses/30/lessons/42889) | [#64](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/64) |
| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
| :----: | :--------: | :-------------: | :-----------------------------------------------------------------------------------------------: | :---------------------------------------------------------: |
| 1์ฐจ์‹œ | 2023.10.07 | BRUTE_FORCE | [BOJ_1107](https://www.acmicpc.net/problem/1107) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/2) |
| 2์ฐจ์‹œ | 2023.10.09 | BRUTE_FORCE | [์—ฐ์† ๋ถ€๋ถ„ ์ˆ˜์—ด ํ•ฉ์˜ ๊ฐœ์ˆ˜](https://school.programmers.co.kr/learn/courses/30/lessons/131701) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/5) |
| 3์ฐจ์‹œ | 2023.10.11 | SORT | [์ตœ์†Ÿ๊ฐ’ ๋งŒ๋“ค๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12941?language=python3) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/8) |
| 4์ฐจ์‹œ | 2023.10.13 | SORT | [ํŠœํ”Œ](https://school.programmers.co.kr/learn/courses/30/lessons/64065) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/9) |
| 5์ฐจ์‹œ | 2023.10.15 | ๊ตฌํ˜„ | [๊ด„ํ˜ธ ๋ณ€ํ™˜](https://school.programmers.co.kr/learn/courses/30/lessons/60058) | [#13](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/13) |
| 6์ฐจ์‹œ | 2023.10.17 | ํƒ์ƒ‰ | [์ฟผ๋“œ์••์ถ• ํ›„ ๊ฐœ์ˆ˜ ์„ธ๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/68936) | [#16](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/16) |
| 7์ฐจ์‹œ | 2023.10.19 | ํƒ์ƒ‰ | [๋ฌด์ธ๋„ ์—ฌํ–‰](https://school.programmers.co.kr/learn/courses/30/lessons/154540) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/20) |
| 8์ฐจ์‹œ | 2023.10.21 | ํƒ์ƒ‰ | [๊ฑฐ๋ฆฌ๋‘๊ธฐ ํ™•์ธํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/81302) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/22) |
| 9์ฐจ์‹œ | 2023.10.23 | ๋งต | [์Šคํ‚ฌ ํŠธ๋ฆฌ](https://school.programmers.co.kr/learn/courses/30/lessons/49993) | [#25](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/25) |
| 10์ฐจ์‹œ | 2023.10.25 | ๊ตฌํ˜„ | [์ˆ˜์‹ ์ตœ๋Œ€ํ™”](https://school.programmers.co.kr/learn/courses/30/lessons/67257) | [#28](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/28) |
| 11์ฐจ์‹œ | 2023.10.27 | ๋ฆฌ์ŠคํŠธ | [์˜์–ด ๋๋ง์ž‡๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12981) | [#30](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/30) |
| 12์ฐจ์‹œ | 2023.10.30 | ํ | [์ด์ค‘์šฐ์„ ์ˆœ์œ„ํ](https://school.programmers.co.kr/learn/courses/30/lessons/42628) | [#36](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/36) |
| 13์ฐจ์‹œ | 2023.11.01 | DP | [๋“ฑ๊ตฃ๊ธธ](https://school.programmers.co.kr/learn/courses/30/lessons/42898) | [#39](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/39) |
| 14์ฐจ์‹œ | 2023.11.03 | ๋งต | [์‹œ์†Œ ์ง๊ฟ](https://school.programmers.co.kr/learn/courses/30/lessons/152996) | [#43](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/43) |
| 15์ฐจ์‹œ | 2023.11.05 | ์ˆ˜ํ•™ | [์˜ˆ์ƒ ๋Œ€์ง„ํ‘œ](https://school.programmers.co.kr/learn/courses/30/lessons/12985) | [#47](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/47) |
| 16์ฐจ์‹œ | 2023.11.08 | ์ˆ˜ํ•™ | [์ˆซ์ž ๋ณ€ํ™˜ํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/154538) | [#51](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/51) |
| 17์ฐจ์‹œ | 2023.11.10 | ์Šคํƒ | [์ง์ง€์–ด ์ œ๊ฑฐํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12973) | [#54](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/54) |
| 18์ฐจ์‹œ | 2023.11.13 | ๊ตฌํ˜„ | [ํ‚คํŒจ๋“œ ๋ˆ„๋ฅด๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/67256) | [#60](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/60) |
| 19์ฐจ์‹œ | 2023.11.17 | ๊ตฌํ˜„ | [์‹คํŒจ์œจ](https://school.programmers.co.kr/learn/courses/30/lessons/42889) | [#64](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/64) |
| 20์ฐจ์‹œ | 2023.11.20 | ๋ฌธ์ž์—ด | [์˜น์•Œ์ด (2)](https://school.programmers.co.kr/learn/courses/30/lessons/133499) | [#70](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/70) |
| 21์ฐจ์‹œ | 2023.11.23 | ๋งต | [์˜์ƒ](https://school.programmers.co.kr/learn/courses/30/lessons/42578) | [#73](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/73) |
| 22์ฐจ์‹œ | 2023.11.26 | ๊ทธ๋ฆฌ๋”” | [๊ตฌ๋ช…๋ณดํŠธ](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | [#79](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/79) |
Expand All @@ -37,4 +37,8 @@
| 33์ฐจ์‹œ | 2024.02.06 | ํ | [์ฒ ๋กœ](https://www.acmicpc.net/problem/13334) | [#132](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/132) |
| 34์ฐจ์‹œ | 2024.02.12 | BFS | [์ด๋ถ„ ๊ทธ๋ž˜ํ”„](https://www.acmicpc.net/problem/1707) | [#135](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/135) |
| 35์ฐจ์‹œ | 2024.02.18 | ๊ทธ๋ฆฌ๋”” | [์„ ๋ฌผํ• ์ธ](https://www.acmicpc.net/problem/25947) | [#137](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/137) |
| 36์ฐจ์‹œ | 2024.02.21 | ์ด์ง„ํƒ์ƒ‰ | [ํœด๊ฒŒ์†Œ ์„ธ์šฐ๊ธฐ](https://www.acmicpc.net/problem/1477) | [#143](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/143) |
| 36์ฐจ์‹œ | 2024.02.21 | ์ด์ง„ํƒ์ƒ‰ | [ํœด๊ฒŒ์†Œ ์„ธ์šฐ๊ธฐ](https://www.acmicpc.net/problem/1477) | [#143](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/143) |
| 37์ฐจ์‹œ | 2024.03.04 | ๊ตฌํ˜„ | [n+1 ์นด๋“œ๊ฒŒ์ž„](https://school.programmers.co.kr/learn/courses/30/lessons/258707) | [#149](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/149) |
| 38์ฐจ์‹œ | 2024.03.08 | BRUTE_FORCE | [์ž๋ฌผ์‡ ์™€ ์—ด์‡ ](https://school.programmers.co.kr/learn/courses/30/lessons/60059) | [#154](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/154) |
| 39์ฐจ์‹œ | 2024.03.19 | ํ | [๋””์Šคํฌ ์ปจํŠธ๋กค๋Ÿฌ](https://school.programmers.co.kr/learn/courses/30/lessons/42627) | [#163](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/163) |
| 40์ฐจ์‹œ | 2024.03.22 | ๊ทธ๋ฆฌ๋”” | [์„ผ์„œ](https://www.acmicpc.net/problem/2212) | [#168](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/168) |
53 changes: 53 additions & 0 deletions pknujsp/๊ตฌํ˜„/37-์นด๋“œ๊ฒŒ์ž„.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
def solution(coin, cards):
a = set(cards[:len(cards) // 3])
b = set()
t = len(cards) + 1
r = 1

for i in range(len(cards) // 3 + 1, len(cards), 2):
c1, c2 = cards[i - 1], cards[i]
b.add(c1)
b.add(c2)

removed = False
# ํ˜„์žฌ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์นด๋“œ ๋ชฉ๋ก ์ค‘ n + 1์ด ๊ฐ€๋Šฅํ•œ ๊ฒฝ์šฐ ํ™•์ธ
for x in list(a):
if t - x in a:
a.remove(t - x)
a.remove(x)
removed = True
break

if removed:
r += 1
continue

# ์ฝ”์ธ์œผ๋กœ ๊ตํ™˜ํ•ด์„œ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์นด๋“œ ์ค‘์—์„œ n + 1์ด ๋˜๋Š” ๊ฒฝ์šฐ๋ฅผ ์ฐพ์•„์•ผ ํ•จ
# ์ฝ”์ธ์ด ์—†์œผ๋ฏ€๋กœ ์ข…๋ฃŒ
if not coin:
break

# `ํ˜„์žฌ ๊ฐ–๊ณ  ์žˆ๋Š” ์นด๋“œ + ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์นด๋“œ` = n + 1์ด ๋˜๋Š” ๊ฒฝ์šฐ๋ฅผ ํ™•์ธ
for x in list(b):
if t - x in a:
a.remove(t - x)
b.remove(x)
removed = True
coin -= 1
break
# ๋งˆ์ง€๋ง‰ ๋ฐฉ๋ฒ•์œผ๋กœ, ์˜ค์ง ๊ตํ™˜์œผ๋กœ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์นด๋“œ ๋ชฉ๋ก ์ค‘์—์„œ n + 1์ด ๋˜๋Š” ๊ฒฝ์šฐ๋ฅผ ํ™•์ธ
if not removed and coin >= 2:
for x in list(b):
if t - x in b:
b.remove(t - x)
b.remove(x)
removed = True
coin -= 2
break

# n + 1์„ ์–ด๋–ค ๊ฒฝ์šฐ์—๋„ ๋ชป ๋งŒ๋“ค๋ฉด ์ข…๋ฃŒ
if not removed:
break
r += 1

return r
18 changes: 18 additions & 0 deletions pknujsp/๊ทธ๋ฆฌ๋””/40-์„ผ์„œ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from sys import *

N = int(stdin.readline())
K = int(stdin.readline())
SENSORS = sorted(set(map(int, stdin.readline().split())))

if K >= N:
print(0)
exit()

distances = [SENSORS[i] - SENSORS[i - 1] for i in range(1, len(SENSORS))]
distances.sort(reverse=True)

result = 0
for i in range(K - 1, len(distances)):
result += distances[i]

print(result)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from heapq import *
from collections import *

def solution(jobs):
jobs = deque(sorted(jobs))
jobs_num = len(jobs)

curr_time = wait_time = 0
heap = []

while heap or jobs:
while jobs and jobs[0][0] <= curr_time:
requested_time, duration = jobs.popleft()
heappush(heap, (duration, requested_time))

if heap:
duration, requested_time = heappop(heap)

curr_time += duration
wait_time += curr_time - requested_time
else:
curr_time += 1

return wait_time // jobs_num