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

23415번 - Boxes on a Shelf 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB121373132.979%

문제

Varya has a barn where she stores $n$ boxes with important stuff. She recently nailed another shelf to the barn wall. Now she wants to put as many boxes as possible on the new shelf.

We shall look at the wall with the shelf as a plane. The shelf is then a horizontal segment of length $L$. There is empty space to the left and to the right of the shelf, which we can consider to be infinite. Box number $i$ is a rectangle with sides $a_i$ and $b_i$.

A box can stand on the shelf and not fall when one of its sides, or a part of it, lies on the shelf, and the center of the box is above an interior point of the shelf. Boxes can be placed only on the shelf, close to the wall: they can not be placed on top of other boxes or in several layers.

Find is the maximum number of boxes Varya can put on the shelf.

입력

The first line contains an integer $n$: the number of boxes (1ドル \le n \le 100,000円$). Each of the following $n$ lines contains two integers $a_i$ and $b_i$: the sides of the respective box (1ドル \le a_i, b_i \le 100,000円$). The last line contains an integer $L$: the length of the shelf (1ドル \le L \le 10^9$).

출력

Print one integer: the maximum number of boxes Varya can put on the shelf so that they don't fall off.

제한

예제 입력 1

4
3 5
6 4
10 20
2 2
7

예제 출력 1

3

예제 입력 2

3
1 1
1 1
1 1
2

예제 출력 2

2

노트

In the first example, Varya can place three boxes on the shelf: for example, the second box lying on side of length 4ドル$ on the left, the fourth box lying on side of length 2ドル$ at the center, and the first box lying on side 3ドル$ on the right.

In the second example, if all three boxes are placed on the shelf symmetrically, they will fall off, as the centers of left and right boxes will be located exactly above the ends of the shelf.

출처

Contest > Open Cup > 2019/2020 Season > Stage 3: Grand Prix of SPb J번

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

출처

대학교 대회

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

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