-
Notifications
You must be signed in to change notification settings - Fork 0
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
6-pu2rile #25
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.
μ λ νμ΄λ΄€λλ° λκ°μ μκ³ λ¦¬μ¦μΌλ‘ νμλ€μ
μ½λ μ λ΄€μ΅λλ€!! λ§μ΄ λ¦μμ§λ§ PR μκ³ νμ
¨μ΄μ~
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.
μ΄ λ¬Έμ λ 그리λ μ νμ΄λΌ κ·Έλ°μ§ λ¬Έμ λ₯Ό μ΄ν΄νλ κ²μ μ¬μ μ΄μ! ν©μ μ΅μκ°μ ꡬν΄μΌνκΈ° λλ¬Έμ μ λ ₯λ°μ κ°μ μ€λ¦μ°¨μμΌλ‘ μ λ ¬νλ€κ³ μκ°νμ΄μ! nλ²μ§Έ μ¬λμ΄ μΈμΆν λ 걸리λ μκ°μ μ΄μ μ μ¬λμ΄ κ±Έλ¦¬λ μκ°κΉμ§ ν©νμ¬ κ³μ°νκΈ° λλ¬Έμ ν©μ μ΅μκ°μ ꡬνκΈ° μν΄μλ μμ μ¬λμ΄ κ±Έλ¦¬λ μκ°μ΄ μ μ μλ‘ μ λ¦¬ν΄ μ²μμ μ€λ¦μ°¨μμΌλ‘ μ λ ¬μ΄ νμν©λλΉ. λλ¨Έμ§λ μνμ μΈ κ°λ μ΄ λ€μ΄κ° κ² κ°μμ!
μ λ νμ΄μ¬μΌλ‘ ꡬνν΄λ΄€λλ°, μλ μ½λ μ°Έκ³ ν΄μ£ΌμΈμ©~
p = int(input()) # ATMμ μ€μ μ μ¬λ μ
pi = list(map(int, input().split())) # κ° μμμ μ¬λλ€μ΄ λμ μΈμΆνλλ° κ±Έλ¦¬λ μκ°
pi.sort() # λμ μΈμΆνλλ° κ±Έλ¦¬λ μκ°μ΄ μ μ μμΌλ‘ μ λ ¬
current_sum = 0 # νμ¬ μ¬λκΉμ§μ λμ μΈμΆνλλ° κ±Έλ¦¬λ μκ°μ ν©
total_waiting_time = 0 # μ 체 λμ μΈμΆνλλ° κ±Έλ¦¬λ μκ°μ ν©
for time in pi:
current_sum += time
total_waiting_time += current_sum
print(total_waiting_time)
μ κΈ°νκ²,,,λνλμ΄λ μμ λκ°μ΄ μ§μ‘μ΄μγ γ μ€μλλ κ°μ μκ³ λ¦¬μ¦μΌλ‘ νμλ€λλ°
λ°λ‘ μμλ΄€λλ°, μ’ λ μνμ μΌλ‘ μ κ·Όν΄λ³Ό μ μλλΌκ΅¬μ.
for i, p in enumerate(pi):
total_waiting_time += p * (p-i)
enumerate()ν¨μλ μμ μ λ°°μ λ κΈ°μ΅μ΄ μλλ° μ κΈ°μ΅λμ§ μλλΌκ΅¬μ. μμ보λ μΈμλ‘ λμ΄μ¨ λͺ©λ‘μ κΈ°μ€μΌλ‘ μΈλ±μ€μ μμλ₯Ό μ°¨λ‘λ‘ μ κ·Όν΄μ£Όλ λ°λ³΅μ κ°μ²΄λ₯Ό λ°νν΄μ£Όλ ν¨μμμ΄μ! μκ³ κ³μ€μ§λ λͺ¨λ₯΄μ§λ§ μ°Έκ³ ν΄λ μ’μ κ² κ°μμ
λ λ°©λ² λͺ¨λ μκ° λ³΅μ‘λκ° κ°μ μ΄λ κ²μ΄ λ ν¨μ¨μ μ΄λ€λΌκ³ λ§νκΈ°λ μ΄λ ΅μ§λ§,, μ΄λ° λ°©λ²λ μμ΄μ μ κΈ°νμ΅λλΉ
λμ μνμ νμ΄λ€ 보λ μ²μμ ꡬνν μ½λλ³΄λ€ μ΄ν΄λ μ΄λ €μ μ΄μ. κ·Έλλ ν¨μλ 곡λΆνκ² λμκ³ μ΄λ° νμ΄λ μλ€λ κ²μ μκ²λμ΄ μ μ΅νμ΅λλ€γ
π λ¬Έμ λ§ν¬
https://www.acmicpc.net/problem/11399
βοΈ μμλ μκ°
20λΆ
β¨ μλ μ½λ
time
μ λν΄ μ£Όκ³ μ΅μλ‘ λμ€λresult
λ₯Ό μΆλ ₯π₯οΈ μ½λ
π μλ‘κ² μκ²λ λ΄μ©