아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Email Filing

시간 제한2초메모리 제한1024 MB

요약
순서대로 주어진 N개의 이메일을 각각 정해진 폴더에 넣어야 하며, 아래로만 스크롤되는 K 크기 창에서 마지막 이메일을 처리하면 위로 한 칸 이동하는 효과가 생긴다. 모든 이메일을 처리할 수 있는지 판정한다.
난이도

보통10점 중 7점

유형
시뮬레이션, 그리디, 구현, 배열
정답자
아직 제출이 없습니다

문제

Farmer John has fallen behind on organizing his inbox. The way his screen is organized, there is a vertical list of folders on the left side of the screen and a vertical list of emails on the right side of the screen. There are MM total folders, numbered 1…M1 \ldots M (1≤M≤104)1 \le M \le 10^4). His inbox currently contains NN emails numbered 1…N1\ldots N (1≤N≤1051 \le N \le 10^5); the iith email needs to be filed into folder f_if\_i (1≤f_i≤M1\le f\_i\le M).

FJ's screen is rather small, so he can only view KK (1≤K≤min⁡(N,M)1\le K\le \min(N,M)) folders and KK emails at once. Initially, his screen starts out displaying folders 1…K1 \ldots K on the left and emails 1…K1 \ldots K on the right. To access other folders and emails, he needs to scroll through these respective lists. For example, if he scrolls down one position in the list of folders, his screen will display folders 2…K+12 \ldots K+1, and then scrolling down one position further it will display folders 3…K+23 \ldots K+2. When FJ drags an email into a folder, the email disappears from the email list, and the emails after the one that disappeared shift up by one position. For example, if emails 1,2,3,4,51, 2, 3, 4, 5 are currently displayed and FJ drags email 3 into its appropriate folder, the email list will now show emails 1,2,4,5,61, 2, 4, 5, 6. FJ can only drag an email into the folder to which it needs to be filed.

Unfortunately, the scroll wheel on FJ's mouse is broken, and he can only scroll downwards, not upwards. The only way he can achieve some semblance of upward scrolling is if he is viewing the last set of KK emails in his email list, and he files one of these. In this case, the email list will again show the last KK emails that haven't yet been filed, effectively scrolling the top email up by one. If there are fewer than KK emails remaining, then all of them will be displayed.

Please help FJ determine if it is possible to file all of his emails.

입력

The first line of input contains TT (1≤T≤101 \le T \le 10), the number of subcases in this input, all of which must be solved correctly to solve the input case. The TT subcases then follow. For each subcase, the first line of input contains MM, NN, and KK. The next line contains f_1…f_Nf\_1 \ldots f\_N.

It is guaranteed that the sum of MM over all subcases does not exceed 10410^4, and that the sum of NN over all subcases does not exceed 10510^5.

출력

Output TT lines, each one either containing either YES or NO, specifying whether FJ can successfully file all his emails in each of the TT subcases.

예제1

  1. 예제 1

    입력
    6
    5 5 1
    1 2 3 4 5
    5 5 1
    1 2 3 5 4
    5 5 1
    1 2 4 5 3
    5 5 2
    1 2 4 5 3
    3 10 2
    1 3 2 1 3 2 1 3 2 1
    3 10 1
    1 3 2 1 3 2 1 3 2 1
    
    예상 출력
    YES
    YES
    NO
    YES
    YES
    NO