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

34863번 - Bookshelf 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB102605460.674%

문제

A bookshelf of length $L$ holds $n$ books, $B_1, \cdots , B_n,ドル arranged from left to right. Each book $B_i$ has a width (thickness) of $w_i$. The heights of the bookshelf and the books are the same. Position $x$ on the shelf corresponds to a point located $x$ units far from the left end. If a book $B_i$ is placed at position $x,ドル it occupies the interval $[x, x + w_i)$ on the shelf. Then the intervals of the books on the shelf are pairwise disjoint. The left end of the shelf is at position 0ドル,ドル the right end is at position $L,ドル and the shelf as a whole occupies the interval $[0, L)$.

Rearranging the books currently on the shelf, you may perform the following operation any number of times:

  • Choose one book $B_i$i on the shelf and take it out, which creates a contiguous empty interval where it was.
  • Then insert $B_i$ into any existing empty interval on the shelf whose length is at least $w_i$.

During this operation, all other books that remain on the shelf stay fixed—cannot slide, move, or be nudged in any way. This is because the books and the shelf have the same height and fit tightly together, so no book can move unless it is explicitly taken out. Also, you are not allowed to push or shift any other books to make room during the operation.

The owner has a favorite book $B_k$ among $n$ books on the shelf and wishes to place it at a specific position $p$.

Given the initial positions of the books on the shelf, the favorite book $B_k,ドル and its target position $p,ドル determine whether it is possible to place $B_k$ at position $p$ after performing any number of the above operations—possibly zero.

입력

Your program is to read from standard input. The input starts with a line containing two integers $n$ and $L$ (1ドル ≤ n ≤ 100,000円$; 1ドル ≤ L ≤ 10^9$), where $n$ is the number of books and $L$ is the length of shelf. The second line contains $n$ distinct integers between 0ドル$ and $L − 1$ (inclusive), representing the positions of books $B_1, \cdots , B_n$ initially arranged on the shelf in ascending order. The third line contains $n$ positive integers, where the $i$-th integer (1ドル ≤ i ≤ n$) is the width $w_i$ of the $i$-th book $B_i$ in the initial arrangement. The next line contains two integers $k$ and $p$ (1ドル ≤ k ≤ n$; 0ドル ≤ p ≤ L − 1$), where the $k$-th book $B_k$ in the initial arrangement is the favorite one and its target position is $p$.

출력

Your program is to write to standard output. Print exactly one line. Print “YES” if it is possible to place the favorite book at the target position, and print “NO” otherwise.

제한

예제 입력 1

3 6
1 3 5
1 2 1
3 3

예제 출력 1

YES

예제 입력 2

3 6
1 3 5
1 2 1
2 5

예제 출력 2

NO

예제 입력 3

3 7
0 3 6
2 3 1
3 1

예제 출력 3

YES

예제 입력 4

3 7
0 3 6
2 3 1
3 4

예제 출력 4

NO

노트

출처

ICPC > Regionals > Asia Pacific > Korea > 2025 ICPC Asia Seoul Regional D번

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

출처

대학교 대회

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

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