ํฐ์คํ ๋ฆฌ ๋ทฐ
๋ฐฑ์ค 18870๋ฒ ๋ฌธ์ ์ ๋๋ค

Xi > Xj ๋ฅผ ๋ง์กฑํ๋๋ก ์ขํ๋ฅผ ์์ถ์ํค๋ผ๊ณ ํฉ๋๋ค.
๋ฌธ์ ๋ง๋ด์๋ ์ดํด๊ฐ ์ ์๊ฐ๋๋ฐ
์ ์ถ๋ ฅ์ ๋ณด์๋ฉด ์ดํด๊ฐ ์ ๊ฐ์ค๊ฒ๋๋ค

2 4 -10 4 -9 ์ขํ๋ 2 3 0 3 1 ์ขํ๋ก ์์ถํ ์ ์๋ค๊ณ ํฉ๋๋ค
-------------------------------------------------------------------------------
ํ์ด ์ ๋๋ค.
๋ฐฐ์ด [-10, -9, 2, 4, 4] ์ด ์๋ค๊ณ ํ๋ฉด 2 4 -10 4 -9 ์ ์์ถ๋ ์ขํ๋ ๋ฐฐ์ด์ index๊ฐ์ด๋ผ๊ณ ๋ณผ ์ ์์ ๊ฒ ๊ฐ์์.
๊ทธ๋์
1. ์ ๋ ฅ๋ฐ์ ๋ฐฐ์ด ์ ๋ ฌ
2. ์ค๋ณต ์ ๊ฑฐ
3. ์ ๋ ฅ๋ฐ์ ๋ฐฐ์ด ์์๋๋ก ์ ๋ ฌ๋ ๋ฐฐ์ด์ index ์ถ๋ ฅ
์ ๋๋ค.
import sys
N = int(input())
inputList = list(map(int,sys.stdin.readline().rstrip().split()))
sortedList = sorted(list(set(inputList)))
dictList = dict(zip(sortedList,list(range(len(sortedList)))))
for x in inputList:
print(dictList[x])
์ค๋ณต ์ ๊ฑฐ๋ setํํ๋ก ๋ง๋ค์ด์ฃผ๊ณ set ํํ๋ฅผ ๋ค์ listํํ๋ก ๋ง๋ค์ด์ฃผ์ด ์ ๊ฑฐํ์์ต๋๋ค
3. ๋ฐฐ์ด๊ฐ ์์๋๋ก ์ ๋ ฌ๋ index๋ฅผ ์ถ๋ ฅํ๊ธฐ ์ํด
์ ๋ key value์ dictionary ์๋ฃ๊ตฌ์กฐ๋ฅผ ์ฌ์ฉํ์์ต๋๋ค
{-10: 0, -9: 1, 2: 2, 4: 3}
์ด๋ ๊ฒ dictList๋ฅผ ๋ง๋ค์์ต๋๋ค
๊ทธ๋ฌ๊ณ inputList์ ๊ฐ๋ค์ dictList์ key๊ฐ์ผ๋ก ๋ฃ์ด์ฃผ๊ฒ ๋๋ฉด
2 3 0 3 1 ์ด๋ ๊ฒ ์ถ๋ ฅ์ด ๋ฉ๋๋ค.
๊ฐ์ฌํฉ๋๋ค.
- Total
- Today
- Yesterday
- swift network refactoring
- swift urlsession ๊ณตํตํ
- ๋ ๋์ธ์ด
- swift urlsession refactoring
- swift ๋คํธ์ํฌ ๋ชจ๋ํ
- ๋น๋๊ธฐ ํ์ด์ง swift
- rag llm pdf
- ๊ณต๋ถ ํ์ด๋จธ ์ดํ
- filemanager excel read
- ios gitignore
- ๋ ๋์ธ์ด ์ดํ
- swift filemanager excel
- swift excel read
- swift get excel
- llm csv
- ๋น๋๊ธฐ ๋ฆฌ์คํธ swift
- swift ์์ ๊ฐ์ ธ์ค๊ธฐ
- chatgpt rag llm
- concurrency pagination
- swift ์์ ์ฝ๊ธฐ
- swift filemanager get excel
- llm pdf rag
- swift ์๊ฐ
- swift git ignore
- ์๋์ํํธ ๋ ์ด์ธ์ด
- rag ๊ธฐ๋ฐ llm
- swift network ๊ณตํตํ
- readysay
- rag ๊ธฐ๋ฐ llm ์ฑ๋ด
- swift network module
| ์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |