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

32478번 - Bookshelf Bottleneck 다국어

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

문제

Brianna is a bookworm. At home, she has a big bookshelf with all her favourite books. She has a large collection ranging from detective novels and science-fiction novels to biographies.

Recently, Brianna has expanded her collection with $n$ graphic novels. However, the new books currently lie around everywhere and form huge stacks on the floor. In the meantime, one of the shelf boards has collected dust and random household utensils that do not belong there. The new books just lying around have become too much to bear, and Brianna finally decided to put them on this shelf board. To do so, she first has to make room on it.

Figure B.1: Visualization of Sample Input 3.

Brianna wants to arrange the books in a single horizontal line without stacking multiple books on top of each other. While the shelf is wide enough to hold all books without problems, it takes time to make room on the shelf. Therefore, Brianna wants to minimize the width of the part of the shelf that she needs to clear.

Each book can be described as a cuboid with three side lengths $l,ドル $w,ドル and $h$. Since the room above the shelf board is limited by the next shelf board above it, she can only fit a book vertically if its vertical side length is at most the distance $H$ between the two shelf boards. Brianna may rotate each book in three-dimensional space as she wants. It is guaranteed that the shelf is deep enough so that the books will not fall off, no matter the orientation. However, all books must stand properly on the shelf board, meaning that every book touches the shelf board along an entire face and not just by an edge.

What is the minimum width of shelf Brianna's books need?

입력

The input consists of:

  • One line with two integers $n$ and $H$ (1ドル\leq n\leq 10^5,ドル 1ドル\leq H \leq 10^9$), the number of books and the height of the shelf, respectively.
  • $n$ lines, each containing three integers $l,ドル $w,ドル $h$ (1ドル\leq l,w,h \leq 10^9$), the dimensions of the books.

출력

Output the minimum width of shelf Brianna's books need, or "impossible" if it is impossible to place the books on the shelf.

제한

예제 입력 1

1 3
10 2 5

예제 출력 1

5

예제 입력 2

1 3
10 4 5

예제 출력 2

impossible

예제 입력 3

2 10
10 2 10
2 3 4

예제 출력 3

4

예제 입력 4

3 1000000000
1000000000 1000000000 1000000000
1000000000 1000000000 1000000000
1000000000 1000000000 1000000000

예제 출력 4

3000000000

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2024 B번

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

출처

대학교 대회

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

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