| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 102 | 60 | 54 | 60.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:
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.
3 6 1 3 5 1 2 1 3 3
YES
3 6 1 3 5 1 2 1 2 5
NO
3 7 0 3 6 2 3 1 3 1
YES
3 7 0 3 6 2 3 1 3 4
NO
ICPC > Regionals > Asia Pacific > Korea > 2025 ICPC Asia Seoul Regional D번