Logo
(追記) (追記ここまで)

30898번 - Arranging Adapters 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 1024 MB259846737.222%

문제

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.

Figure A.1: 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.

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.

Your power strip comprises a row of $s$ sockets, and each socket is 3ドル \text{cm}$ 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. Now you challenge them to charge as many devices as possible. 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 $n$ and $s$ $(1\leq n\leq2\cdot 10^5,ドル 1ドル\leq s\leq10^9),ドル the number of chargers you have and the number of sockets on the power strip.
  • One line with $n$ integers $w$ (3ドル\leq w\leq10^9$), the width of each charger in centimetres.

Note that you are allowed to rotate chargers by 180ドル^\circ$ before plugging them in.

출력

Output the maximum number of chargers you can plug into the power strip at the same time.

제한

예제 입력 1

5 7
7 4 4 5 8

예제 출력 1

5

예제 입력 2

8 9
7 4 3 6 4 8 5 6

예제 출력 2

6

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2023 A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /