๋ชฉ๋กdeque (1)

๐ŸŒฑ → ๐ŸŒณ

[๋ฐฑ์ค€] 10866๋ฒˆ: ๋ฑ python

https://www.acmicpc.net/problem/10866 10866๋ฒˆ: ๋ฑ ์ฒซ์งธ ์ค„์— ์ฃผ์–ด์ง€๋Š” ๋ช…๋ น์˜ ์ˆ˜ N (1 ≤ N ≤ 10,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ N๊ฐœ์˜ ์ค„์—๋Š” ๋ช…๋ น์ด ํ•˜๋‚˜์”ฉ ์ฃผ์–ด์ง„๋‹ค. ์ฃผ์–ด์ง€๋Š” ์ •์ˆ˜๋Š” 1๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , 100,000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™๋‹ค. ๋ฌธ์ œ์— ๋‚˜์™€์žˆ์ง€ www.acmicpc.net ๋ฌธ์ œ ์ •๋ณด ๋ฌธ์ œ ์œ ํ˜• ๋‚œ์ด๋„ ๊ฑธ๋ฆฐ ์‹œ๊ฐ„ ์Šค์Šค๋กœ ๊ตฌํ˜„ ์„ฑ๊ณต ๋ฑ ์‹ค๋ฒ„4 10m O ์„ค๊ณ„ ๋ฐฉ๋ฒ• ๋‚ด๊ฐ€ ๊ตฌํ˜„ํ•œ ๋ฐฉ๋ฒ• ๋ฑ ํด๋ž˜์Šค ์ƒ์„ฑ ํ›„ ๊ฐ ๋ฉ”์†Œ๋“œ ๊ตฌํ˜„ ๋‹ค๋ฅธ ํ’€์ด 1 ๊ฐ„๋‹จํ•˜๊ฒŒ deque ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•œ ํ’€์ด ๋‹ค๋ฅธ ํ’€์ด 2 dictionary๋ฅผ ์ด์šฉํ•˜์—ฌ switch-case๋ฌธ์„ ๊ตฌํ˜„ ์ด๋ฅผ ์ด์šฉํ•˜์—ฌ key๊ฐ’์„ ๊ฐ€์ง€๊ณ  ๋”•์…”๋„ˆ๋ฆฌ์— ์ ‘๊ทผํ•˜์—ฌ ๋Œ€์‘๋˜๋Š” value๊ฐ’์„ ํ†ตํ•ด ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœ ์ฝ”๋“œ ๋‚ด ํ’€์ด im..

Algorithms 2023. 1. 8. 17:27