[BOJ- 11399] ATM

yuseon Limยท2021๋…„ 6์›” 15์ผ
0

Problem Solving

๋ชฉ๋ก ๋ณด๊ธฐ
26/37
post-thumbnail
post-custom-banner

๐Ÿค’ ๋ฌธ์ œ

BOJ-1931 ATM

๐Ÿ’Š ํ’€์ด

p1, p2, p3, p4, p5 ์ˆœ์„œ๋กœ ์ค„์„ ์„ ๋‹ค๊ณ  ํ•˜๋ฉด
๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„ = (p1) + (p1+p2) + (p1+p2+p3) + (p1+p2+p3+p4) + (p1+p2+p3+p4+p5)
์ด ๋  ๊ฒƒ์ด๋‹ค.

์ค„์„ ์•ž์œผ๋กœ ์„ค ์ˆ˜๋ก ์‹œ๊ฐ„ ๊ณ„์‚ฐ์—์„œ ๋” ๋งŽ์ด ๋”ํ•ด์ง€๊ฒŒ ๋˜๋ฏ€๋กœ ๊ฐ„๋‹จํ•˜๊ฒŒ, ์‹œ๊ฐ„์ด ์˜ค๋ž˜ ๊ฑธ๋ฆฌ๋Š” ์‚ฌ๋žŒ์ผ์ˆ˜๋ก ๋’ค์— ์„œ๋ฉด๋œ๋‹ค.

  1. ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ฆฌ
  2. slice ํ•œ list๋ฅผ for๋ฌธ์„ ๋Œ๋ฉฐ ์ฐจ๋ก€๋กœ ๋”ํ•ด์คŒ

โœจ ์†Œ์Šค์ฝ”๋“œ

N = int(input())
nums = list(map(int, input().split()))

nums.sort() # ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌ
time = 0
for i in range(len(nums)) :
    time += sum(nums[0:i+1])

print(time)

profile
๐Ÿ”ฅhttps://devyuseon.github.io/ ๋กœ ์ด์‚ฌ์ค‘ ์ž…๋‹ˆ๋‹ค!!!!!๐Ÿ”ฅ
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€