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

32900번 - Limited Library 다국어

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

문제

During the summer break, fewer students are dwelling on campus, so this is the perfect time to add new books to the TU Delft library. These new books all have the same width, but they have varying heights. Because all existing bookcases are already full, the management board of the library has decided that they will add a new bookcase to display these new books.

The new bookcase has a number of shelves with varying heights. Each shelf in the bookcase can fit $x$ books. Since there may be some leftover space, the management board would also like to display some art pieces in this bookcase, at most one per shelf. An art piece will only fit on a shelf if there are at most $y$ books next to it, because the art pieces take up the same amount of space as $x-y$ books. As an example, Figure L.1 shows a bookcase where three of the shelves have enough space for an art piece.

Figure L.1: Illustration of Sample Input 1. Three shelves can have art pieces in the hatched areas, while still fitting all new books.

The management board wants you to find the largest number of shelves on which you can place an art piece, whilst also being able to fit all the new books on the shelves.

입력

The input consists of:

  • One line with four integers $n,ドル $m,ドル $x,ドル and $y$ (1ドル \leq n, m \leq 10^5,ドル 1ドル \leq y < x \leq 1000$), the number of shelves, the number of books, the number of books that fit on a full shelf, and the number of books that fit on a shelf next to an art piece.
  • One line with $n$ integers $a$ (1ドル \leq a \leq 10^9$), the heights of the shelves.
  • One line with $m$ integers $b$ (1ドル \leq b \leq 10^9$), the heights of the books.

출력

If it is possible to fit all the $m$ books into the $n$ shelves, output the largest number of art pieces you can place. Otherwise, output "impossible".

제한

예제 입력 1

4 8 4 2
4 8 6 2
1 2 3 5 7 7 8 8

예제 출력 1

3

예제 입력 2

4 11 3 2
2 2 2 2
1 1 1 1 1 1 1 1 1 1 1

예제 출력 2

1

예제 입력 3

2 10 3 2
8 6
4 2 1 3 6 2 1 3 4 5

예제 출력 3

impossible

예제 입력 4

3 8 8 3
7 9 4
2 3 4 5 6 7 8 9

예제 출력 4

3

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2024 L번

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

출처

대학교 대회

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

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