-
Notifications
You must be signed in to change notification settings - Fork 2
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
18-H0ngJu #199
18-H0ngJu #199
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import sys | ||
sys.setrecursionlimit(10**6) | ||
|
||
def input(): return sys.stdin.readline().rstrip() | ||
|
||
N = int(input()) | ||
eggs = [list(map(int, input().split())) for _ in range(N)] | ||
|
||
def break_egg(idx): | ||
cnt = 0 | ||
|
||
# idxκ° λμ΄κ° κ²½μ° | ||
if idx == N: | ||
for i in range(N): | ||
if eggs[i][0] <= 0: | ||
cnt += 1 | ||
return cnt | ||
|
||
if eggs[idx][0] <= 0: # λ€κ³ μλ κ³λμ΄ κΉ¨μ§ κ²½μ° | ||
return break_egg(idx+1) | ||
|
||
broken = False | ||
for j in range(N): # κ³λ κΉ¨κΈ° | ||
if j != idx and eggs[j][0] > 0: | ||
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. λ°λ‘ μ¬μν κΆκΈμ μΈλ°... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μ μ jλκ³ λ¬ΌμΌμ λ€λ©΄ .... i λ€μμ j μ°λκ² μ΅κ΄μ΄μ΄μ |
||
broken = True | ||
eggs[idx][0] -= eggs[j][1] | ||
eggs[j][0] -= eggs[idx][1] | ||
|
||
cnt = max(cnt, break_egg(idx+1)) | ||
|
||
eggs[idx][0] += eggs[j][1] | ||
eggs[j][0] += eggs[idx][1] | ||
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μ λ μ¬κΈ°μ λλ €μ£Όμ§μκ³ κ·Έλ₯ λ§€λ² μλ‘μ΄ λ¦¬μ€νΈλ₯Ό μμ±ν©λλ€! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. λ§€λ² μλ‘μ΄ λ¦¬μ€νΈλ₯Ό μμ±νλ©΄ μμ κ°μ΄ λ°±νΈλνΉ λ°©μμΌλ‘ κ°λ€κ° λ€μ λλλ €λμΌλ©΄ |
||
|
||
if not broken: | ||
return break_egg(idx+1) | ||
|
||
return cnt | ||
|
||
print(break_egg(0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ°±νΈλνΉ ν¨μμ μΈμλ‘ "κ³λμ λͺ κ° κΉΌλκ°" μ 보λ₯Ό κ°μ΄ λκ²¨μ£Όκ² λλ©΄ μ‘°κΈ λ ν¨μ¨μ μΌλ‘ λμνκ² λ§λ€ μ μμ΅λλ€
broken μΈμλ₯Ό λ€κ³ μκΈ° λλ¬Έμ 리μ€νΈλ₯Ό μνν΄μ κΉ¨μ§ κ³λ κ°μλ₯Ό μΉ΄μ΄ν νλ κ³Όμ μμ²΄κ° μ¬λΌμ§λλ€.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ μ½λμ κ²½μ°μ μ¬κ· μ νμ μνμ΄μ€λ λλλΌκ΅¬μ :)