포럼
문제 ICPC00382

B. Bookshelf Bottleneck

설명

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.

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
출력
5
예제 2
입력
1 3
10 4 5
출력
impossible
예제 3
입력
2 10
10 2 10
2 3 4
출력
4
예제 4
입력
3 1000000000
1000000000 1000000000 1000000000
1000000000 1000000000 1000000000
1000000000 1000000000 1000000000
출력
3000000000
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC GCPC 2024

평가 및 의견

B. Bookshelf Bottleneck

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

B. Bookshelf Bottleneck

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8