-
Notifications
You must be signed in to change notification settings - Fork 1
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
12-mong3125 #41
12-mong3125 #41
Conversation
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.
μ΄κ±° λͺ μΌ λμ κ³ λ―Όνλ€κ° κ²°κ΅ λͺ» νμλλ° μ΄λΆνμ μ΄μκ΅°μ..
λ체 μ΄λ° νμ΄λ₯Ό μ΄λ»κ² νλ κ±΄μ§ μΆμ΄μ κ³μ μ½μ΄λ³΄κ² λλ€μ.
ν μ μ»μ΄κ°λλ€. μκ³ νμ
¨μ΅λλ€.
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.
μμΌλ‘ νκΈ°λ μ΄λ €μ΄ κ±Έ μ΄λ»κ² μ½λλ‘ κ΅¬νν μ§ λ§μ°ν΄ 보μλλ° μ΄λΆνμμ μ΄μ©νλ©΄ κ°λ¨νκ³ λΉ λ₯΄κ² ꡬνν μ μκ΅°μ.
μ΄λΆνμλ§ μκ°ν΄λΈλ€λ©΄ mid
κ°μΌλ‘ λ
Ήνκ° κ°λ₯νμ§ νλ
νλ 쑰건μ ꡬννλ κ²μ΄ μ΄ λ¬Έμ μ ν΅μ¬μΌλ‘ 보μ
λλ€.
public static boolean can(int blueray) { | ||
int count = M; | ||
int i = 0; | ||
int stack = blueray; | ||
while (count > 0) { | ||
while (stack - lectures[i] > 0) { | ||
if (i == N) return true; | ||
stack -= lectures[i]; | ||
i++; | ||
} | ||
|
||
stack = blueray; | ||
count--; | ||
} | ||
|
||
return false; |
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.
μμ can()
ν¨μλ‘ mid
μ¬μ΄μ¦λ‘ λ
Ήνκ° κ°λ₯νμ§ νλ
νλκ±Έλ‘ λ³΄μ
λλ€.
mid
κ°μ λ΄μ stack
μμ κ°μμκ°μ νλμ© λΉΌκ°λ©΄μ λͺ¨λ κ°μκ° M
κ°μ λΈλ£¨λ μ΄μ λ΄κΈΈ μ μλμ§ νλ
νλκ²μΌλ‘ μ΄ν΄νλ©΄ λ κΉμ?
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.
λ€ λ§μ΅λλ€!
π λ¬Έμ λ§ν¬
κΈ°ν λ μ¨
βοΈ μμλ μκ°
λͺ» νκ³ μμ΄λμ΄ λ΄
λ³΄κ³ λμ 30λΆ
β¨ μλ μ½λ
λ¬Έμ μ€λͺ
μ λ ₯μΌλ‘
N M
l[0], l[1], l[2]...
μ΄λ κ² λ€μ΄μ€λλ° Nμ lμ κΈΈμ΄μ΄κ³ Mμ λ μ½λ κ°μμ λλ€. lμ κ°μμμ κΈΈμ΄μ΄κ³ μ.
κ°μλ μ°μν΄μ μ μ₯μ ν΄μΌν©λλ€. μ΄ λ λ μ½λ κ°μλ΄λ‘ μ μ₯νκΈ° μν΄μ λ μ½λ μ΅μ κΈΈμ΄λ₯Ό ꡬνλ λ¬Έμ μ λλ€.
λ¬Έμ λ κΈ΄λ° μ΄ν΄νλ©΄ μ΄λ κ² κ°λ¨νκ² μ΄ν΄ν μ μμ΅λλ€.
π μλ‘κ² μκ²λ λ΄μ©