시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
6 초 | 512 MB | 107 | 32 | 28 | 33.735% |
We have a knapsack of integral capacity and some objects of assorted integral sizes. We attempt to fill the knapsack up, but unfortunately, we are really bad at it, so we end up wasting a lot of space that can’t be further filled by any of the remaining objects. In fact, we are optimally bad at this! How bad can we possibly be?
Figure out the least capacity we can use where we cannot place any of the remaining objects in the knapsack. For example, suppose we have $3$ objects with weights $3$, $5$ and $3$, and our knapsack has capacity $6$. If we foolishly pack the object with weight $5$ first, we cannot place either of the other two objects in the knapsack. That’s the worst we can do, so $5$ is the answer.
The first line of input contains two integers $n$ ($1 \le n \le 1,000$) and $c$ ($1 \le c \le 10^5$), where $n$ is the number of objects we want to pack and $c$ is the capacity of the knapsack.
Each of the next $n$ lines contains a single integer $w$ ($1 \le w \le c$). These are the weights of the objects.
Output a single integer, which is the least capacity we can use where we cannot place any of the remaining objects in the knapsack.
3 6 3 5 3
5
ICPC > Regionals > North America > Southeast USA Regional > 2020 Southeast USA Regional Programming Contest B번
ICPC > Regionals > North America > Mid-Central Regional > 2020 Mid-Central Regional Programming Contest J번
ICPC > Regionals > North America > Pacific Northwest Regional > 2020 ICPC Pacific Northwest Region > Division 1 M번
ICPC > Regionals > North America > Pacific Northwest Regional > 2020 ICPC Pacific Northwest Region > Division 2 AD번
ICPC > Regionals > North America > Mid-Atlantic Regional > 2020 Mid-Atlantic USA Regional Contest F번
ICPC > Regionals > North America > South Central USA Regional > 2020 South Central USA Regional Contest B번