-
Notifications
You must be signed in to change notification settings - Fork 5
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
11 ljedd2 #161
11 ljedd2 #161
Conversation
λ¬Έμμ΄ νμ΄
This reverts commit 3f50541.
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.
8μ°¨μ PR λ μ΄ λ¬Έμ λ₯Ό νλ² νμ΄λ³΄μλλ° μ μλμ΄ νΈμ ¨λ λ‘μ§κ³Ό κ±°μ λμΌνλ€μ! μ λ μ²μμλ Nκ°μ μλ₯Ό heapμ λ£μ λ€μ λ€μ μλΆν°λ Nλ²μ§Έ ν° μλ³΄λ€ κ·Έ λ€μ νμ μ«μκ° λ ν¬λ€λ©΄, heapμλ κ·Έ λ€μ νμ μ«μλ₯Ό λμ λ£κ³ μλλ©΄ λ£μ§ μλ λ°©μμΌλ‘ νμμ΅λλ€π
μ΄λ² PRλ μκ³ νμ ¨μ΅λλ€π»
|
||
else: | ||
if number > heap[0]: # μ μΌ μμκ²λ³΄λ€ ν¬λ©΄ | ||
heapq.heapreplace(heap, number) #μμκ±° λΉΌκ³ ν°κ±° λ£μ΄μ€ |
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.
μ°μ! νμ΄μ¬ heapq λͺ¨λ μ€μμ heapreplace
ν¨μλΌλ κ²μ΄ μμκ΅°μ!
μ μλ λλΆμ heapreplace
ν¨μκ° heapμμ μ΅μκ°μ μ κ±°νκ³ itemμ μΆκ°νλ μν μ νλ€λ κ²μ μμκ°λλ€π«’
λ€μμ μ λ νλ² μ¨λ³΄κ² μ΅λλ·!
π λ¬Έμ λ§ν¬
λ°±μ€ μ°μ μμ ν | BOJ 2075 Nλ²μ§Έ ν° μ
λ¬Έμ μ€λͺ
NΓNμ νμ μ N2κ° μ±μμ Έ μλ€. μ±μμ§ μμλ ν κ°μ§ νΉμ§μ΄ μλλ°, λͺ¨λ μλ μμ μ ν μΉΈ μμ μλ μλ³΄λ€ ν¬λ€λ κ²μ΄λ€. N=5μΌ λμ μλ₯Ό 보μ.
μ΄λ¬ν νκ° μ£Όμ΄μ‘μ λ, Nλ²μ§Έ ν° μλ₯Ό μ°Ύλ νλ‘κ·Έλ¨μ μμ±νμμ€.
μ ν 쑰건
첫째 μ€μ **N(1 β€ N β€ 1,500)**μ΄ μ£Όμ΄μ§λ€.
λ€μ Nκ°μ μ€μλ κ° μ€λ§λ€ Nκ°μ μκ° μ£Όμ΄μ§λ€.
νμ μ ν μλ -10μ΅λ³΄λ€ ν¬κ±°λ κ°κ³ , 10μ΅λ³΄λ€ μκ±°λ κ°μ μ μμ΄λ€.
βοΈ μμλ μκ°
1μκ°
β¨ μλ μ½λ
μ°μ μμν μ ν λ¬Έμ νΈλλ° μ¬λ―Έκ° λ€λ € λμ ν΄λ³Έ λ¬Έμ μ λλ€!
μΌλ¨ κ° μ€μ μ£Όμ΄μ§ μμ λ²μκ° μ μμΌλ‘ 10μ΅μ΄κΈ° λλ¬Έμ μΌλ°μ μΈ μ κ·ΌμΌλ‘λ μ΄λ¦Όλ μλ€λ κ²μ λλ μ μμμ΅λλ€.
λ°λΌμ N^2μ μ«μλ€μ λͺ¨λ μ΄ν΄λ³΄λ©΄μ λ‘μ§μ μννλ μ΄λ¬ν μ λ ₯λ€μ ν¬κΈ°κ° N μ§λ¦¬ μ°μ μμ νμμ μ²λ¦¬ν΄μ£Όμ΄μΌ ν©λλ€.
λ¬Έμ νμ΄ κ³Όμ
->Β μ°μ μμ νμ μ΅μκ°μ μ κ±°, νμ¬ νμΈνκ³ μλ μ«μλ₯Ό μ°μ μμ νμ μ½μ ν©λλ€.
μ κ³Όμ μ νμ΄μ°λ©΄ μλμ κ°μ΅λλ€
heappush()λ₯Ό μ΄μ©νλ©΄, μ°μ μμμ λ°λ₯Έ μ λ ¬μ΄ μΌμ΄λλ―λ‘ μ°Ύλ κ°μ΄ 맨 μμΌλ‘ μ¬ λ κΉμ§ 맨 μ κ°μ κ³μ μ κ±°ν΄μ£Όκ³ , Nλ²μ§Έ ν° κ°μ μΆλ ₯ν μ μκ² λ©λλ€.
μ΅μ’ μ½λ
π μλ‘κ² μκ²λ λ΄μ©