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

20902번 - Bookshelf Building 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB105474546.392%

문제

Anna just came home from her favourite furniture store Ikey Yeah! where she bought a new bookshelf designed by her favourite artist Bill Lee. The shelf has a rectangular shape with a width of $x$ and a height of $y$. Included in the box of the shelf is one board that Anna may put horizontally inside the shelf. For this purpose the frame of the shelf already contains pre-drilled holes at heights 1,2,ドル\ldots,y-1$. Anna may attach the board to the frame at any of these heights. She can also decide not to install it at all.

Anna owns $n$ books, which all have the same depth. The books' depth matches that of the shelf exactly. However, due to differences in the formats and the numbers of pages, her books may have different widths and heights. Anna does not want to flip her books or stack several of them on top of each other. Instead, she wants to store all of them in an upright fashion inside her bookshelf, such that the width and height of each book are aligned with the width and height of the bookshelf. Help Anna to find the perfect position for the board (or tell her not to use it at all) so that she can store all her books in her new bookshelf.

For this problem you may assume that the frame and the board of the shelf are infinitely thin.

입력

The input consists of:

  • One line with three integers $n,ドル $x$ and $y,ドル where
    • $n$ (1ドル \le n \le 10^4$) is the number of books that Anna owns;
    • $x$ (1ドル \le x \le 10^4$) is the width of the bookshelf frame;
    • $y$ (1ドル \le y \le 10^4$) is the height of the bookshelf frame.
  • $n$ lines, the $i$th of which contains two integers $w_i$ and $h_i,ドル where
    • $w_i$ (1ドル \le w_i \le 10^4$) is the width of the $i$th book;
    • $h_i$ (1ドル \le h_i \le 10^4$) is the height of the $i$th book.

출력

If there is no possibility to store Anna's books in the shelf, print out impossible. In case Anna decides not to install the board, output $-1$. Otherwise, output the height at which the board should be installed. If there are multiple possible heights, you may output any one of them.

제한

예제 입력 1

4 4 4
3 1
1 1
1 3
2 2

예제 출력 1

3

예제 입력 2

2 4 3
2 3
1 1

예제 출력 2

-1

예제 입력 3

3 3 3
2 2
2 1
2 1

예제 출력 3

impossible

힌트

출처

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

  • 문제를 만든 사람: Gregor Schwarz
(追記) (追記ここまで)

출처

대학교 대회

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

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