#P13700. [NWERC 2023] Arranging Adapters
[NWERC 2023] Arranging Adapters
题目背景
It is the day before the NWERC and you and your team are on the train towards Delft. The journey is long and boring but you came up with a good idea: "Let's do some training".
-- silence --
题目描述
You take your laptop out and try to plug it in when you notice that the only socket is already in use. Your friends smirk and reply: "No socket for you, no training for us". Their smirks quickly fade as you pull out a power strip, unplug the charger from the socket, and plug it back into the power strip. Now, there is enough space for your charger as well.
However, as soon as more sockets are available, your friends suddenly take out more devices that need to be charged. You realize that you will not get them to train like this, so you decide to trick them into solving a problem instead.
:::align{center} Illustration of Sample Input 2. The first six chargers can be plugged in as shown. Note that this is not the only possible solution. However, it can be shown that it is impossible to plug in all seven chargers. :::
Your power strip comprises a row of sockets, and each socket is in diameter. Furthermore, as you examine the chargers, you notice that they all have integer lengths. The plug of each charger is always on one of the two ends, and each charger can only be used in two orientations. Chargers cannot overlap, but can touch, and can extend beyond the end of the power strip as long as they are plugged in to a socket. This is visualized in Figure A.1. Hoping that this allows them to avoid the training, your friends agree to write a program to solve this.
输入格式
The input consists of:
- One line with two integers and , , the number of chargers you have and the number of sockets on the power strip.
- One line with integers (), the width of each charger in centimetres.
Note that you are allowed to rotate chargers by before plugging them in.
输出格式
Output the maximum number of chargers you can plug into the power strip at the same time.
5 7
7 4 4 5 8
5
8 9
7 4 3 6 4 8 5 6
6