์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ/BOJ_Python

[BOJ/Step12] 18870 : ์ขŒํ‘œ ์••์ถ• (Python)

NaNaRin๐Ÿ™ƒ 2021. 6. 25. 16:23

https://www.acmicpc.net/problem/18870

 

18870๋ฒˆ: ์ขŒํ‘œ ์••์ถ•

์ˆ˜์ง์„  ์œ„์— N๊ฐœ์˜ ์ขŒํ‘œ X1, X2, ..., XN์ด ์žˆ๋‹ค. ์ด ์ขŒํ‘œ์— ์ขŒํ‘œ ์••์ถ•์„ ์ ์šฉํ•˜๋ ค๊ณ  ํ•œ๋‹ค. Xi๋ฅผ ์ขŒํ‘œ ์••์ถ•ํ•œ ๊ฒฐ๊ณผ X'i์˜ ๊ฐ’์€ Xi > Xj๋ฅผ ๋งŒ์กฑํ•˜๋Š” ์„œ๋กœ ๋‹ค๋ฅธ ์ขŒํ‘œ์˜ ๊ฐœ์ˆ˜์™€ ๊ฐ™์•„์•ผ ํ•œ๋‹ค. X1, X2, ..., XN์— ์ขŒ

www.acmicpc.net


์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•์„ ์จ๋ดค๋Š”๋ฐ ๋‹ค ์‹œ๊ฐ„์ดˆ๊ณผ...

์ž…๋ ฅ ๋ฐฉ๋ฒ•๋•Œ๋ฌธ์ธ๊ฐ€ ์‹ถ์–ด์„œ sys ๋ชจ๋“ˆ readline ํ•จ์ˆ˜๋กœ๋„ ๋ฐ”๊ฟ”๋ดค๋Š”๋ฐ ๊ณ„์† ์‹œ๊ฐ„์ดˆ๊ณผ๊ฐ€ ๋‚œ๋‹ค ๋ญ๋•Œ๋ฌธ์ผ๊นŒ?..

 

๊ทธ๋ƒฅ ๋„ˆ๋ฌด ์˜ค๋ž˜ ๊ฑธ๋ ค์„œ ์‹œ๊ฐ„์ดˆ๊ณผ์˜€์Œ ใ…Ž..

๋จธ๋ฆฌ๊ฐ€ ๋‹ค ๊ตณ์–ด๋ฒ„๋ฆฐ๊ฑฐ๊ฐ™๋‹ค ๊ณ„์† ์‹œ๊ฐ„์ดˆ๊ณผ๋‚˜์„œ ์ฐพ์•„๋ดค๋Š”๋ฐ๋„ ์ดํ•ด๊ฐ€ ์•ˆ๋˜์„œ ํ•œ์ฐธ ๋ฒ„๋ฒ…๋Œ

์งง๊ณ  ๊ฐ„๋‹จํ•˜๊ฒŒ ํ’€๋ฆฌ๋Š” ๋ฌธ์ œ์˜€๋Š”๋ฐ ๋”•์…”๋„ˆ๋ฆฌ ๋„ˆ๋ฌด ์˜ค๋žœ๋งŒ์ด๋ผ ๋” ๊ทธ๋žฌ๋˜ ๋“ฏ..

 

# 18870.py

num = int(input())
l1 = list(map(int, input().split()))
l2 = sorted(list(set(l1)))

after = {l2[i]: i for i in range(len(l2))}

for i in l1:
    print(after[i], end=' ')