๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์ˆ˜๋“ค์˜ ํ•ฉ1

[๋ฐฑ์ค€/C++] 2015๋ฒˆ : ์ˆ˜๋“ค์˜ ํ•ฉ 4 ๋ฌธ์ œ A[1], A[2], ..., A[N]์˜ N๊ฐœ์˜ ์ •์ˆ˜๊ฐ€ ์ €์žฅ๋˜์–ด ์žˆ๋Š” ๋ฐฐ์—ด์ด ์žˆ๋‹ค. ์ด ๋ฐฐ์—ด A์˜ ๋ถ€๋ถ„ํ•ฉ์ด๋ž€ 1 ≤ i ≤ j ≤ N์ธ ์ •์ˆ˜ i์™€ j์— ๋Œ€ํ•ด A[i]๋ถ€ํ„ฐ A[j]๊นŒ์ง€์˜ ํ•ฉ์„ ๋งํ•œ๋‹ค. N๊ณผ A[1], A[2], ..., A[N]์ด ์ฃผ์–ด์กŒ์„ ๋•Œ, ์ด๋Ÿฌํ•œ N×(N+1)/2๊ฐœ์˜ ๋ถ€๋ถ„ํ•ฉ ์ค‘ ํ•ฉ์ด K์ธ ๊ฒƒ์ด ๋ช‡ ๊ฐœ๋‚˜ ์žˆ๋Š”์ง€๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…๋ ฅ ์ฒซ์งธ ์ค„์— ์ •์ˆ˜ N๊ณผ K๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (1 ≤ N ≤ 200,000, |K| ≤ 2,000,000,000) N๊ณผ K ์‚ฌ์ด์—๋Š” ๋นˆ์นธ์ด ํ•˜๋‚˜ ์žˆ๋‹ค. ๋‘˜์งธ ์ค„์—๋Š” ๋ฐฐ์—ด A๋ฅผ ์ด๋ฃจ๋Š” N๊ฐœ์˜ ์ •์ˆ˜๊ฐ€ ๋นˆ ์นธ์„ ์‚ฌ์ด์— ๋‘๊ณ  A[1], A[2], ..., A[N]์˜ ์ˆœ์„œ๋กœ ์ฃผ์–ด์ง„๋‹ค. ์ฃผ์–ด์ง€๋Š” ์ •์ˆ˜์˜ ์ ˆ๋Œ“๊ฐ’์€ 10,000์„ ๋„˜์ง€ ์•Š๋Š”๋‹ค. ์ถœ๋ ฅ ์ฒซ์งธ ์ค„์—.. 2021. 9. 12.