๋ชฉ๋ก๋ƒ…์ƒ‰ (1)

Hello Ocean! ๐ŸŒผ

[๋ฐฑ์ค€/C++] 12865. ํ‰๋ฒ”ํ•œ ๋ฐฐ๋‚ญ

๋ฌธ์ œ www.acmicpc.net/problem/12865 12865๋ฒˆ: ํ‰๋ฒ”ํ•œ ๋ฐฐ๋‚ญ ์ฒซ ์ค„์— ๋ฌผํ’ˆ์˜ ์ˆ˜ N(1 ≤ N ≤ 100)๊ณผ ์ค€์„œ๊ฐ€ ๋ฒ„ํ‹ธ ์ˆ˜ ์žˆ๋Š” ๋ฌด๊ฒŒ K(1 ≤ K ≤ 100,000)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๋‘ ๋ฒˆ์งธ ์ค„๋ถ€ํ„ฐ N๊ฐœ์˜ ์ค„์— ๊ฑฐ์ณ ๊ฐ ๋ฌผ๊ฑด์˜ ๋ฌด๊ฒŒ W(1 ≤ W ≤ 100,000)์™€ ํ•ด๋‹น ๋ฌผ๊ฑด์˜ ๊ฐ€์น˜ V(0 ≤ V ≤ 1,000) www.acmicpc.net ํ’€์ด ์ฒ˜์Œ์—๋Š”, DP๋ฅผ ์–ด๋–ป๊ฒŒ ์ด์šฉํ•ด์•ผํ• ์ง€ ๋– ์˜ค๋ฅด์ง€ ์•Š์•„์„œ ์ผ๋‹จ ์™„์ „ํƒ์ƒ‰์œผ๋กœ ๊ตฌํ˜„ํ•ด๋ณด์•˜๋‹ค. ๊ฒฐ๊ณผ๋Š” ๋„ˆ๋ฌด ๋‹น์—ฐํ•˜๊ฒŒ๋„ ์‹œ๊ฐ„์ดˆ๊ณผ์˜€๋‹ค! ์™„์ „ํƒ์ƒ‰์œผ๋กœ ๊ตฌํ˜„ํ•˜๊ณ  ๋‚˜๋ฉด, DP์— ๋Œ€ํ•œ ๊ฐ์ด ์˜ฌ๊ฑฐ๋ผ๊ณ  ์ƒ๊ฐํ–ˆ๋Š”๋ฐ ์ „ํ˜€ ์˜ค์ง€ ์•Š์•˜๋‹ค. ๊ฒฐ๊ตญ ๊ฒ€์ƒ‰์˜ ํž˜์„ ๋นŒ๋ ธ๋Š”๋ฐ, ์ด ๋ฌธ์ œ๋Š” ๋Œ€ํ‘œ์ ์ธ "๋ƒ…์ƒ‰ ๋ฌธ์ œ"๋ผ๊ณ  ํ•œ๋‹ค. ๋ƒ…์ƒ‰ ๋ฌธ์ œ(knapsack problem)๋ž€? ๋ƒ…์ƒ‰ ๋ฌธ..

Algorithm 2021. 3. 14. 23:33