luogu#P8188. [USACO22FEB] Email Filing S
[USACO22FEB] Email Filing S
题目描述
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 total folders, numbered . His inbox currently contains emails numbered ; the th email needs to be filed into folder .
FJ's screen is rather small, so he can only view folders and emails at once. Initially, his screen starts out displaying folders on the left and emails 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 , and then scrolling down one position further it will display folders . 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 are currently displayed and FJ drags email 3 into its appropriate folder, the email list will now show emails . FJ can only drag an email into the folder to which it needs to be filled.
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 emails in his email list, and he files one of these. In this case, the email list will again show the last emails that haven't yet been filed, effectively scrolling the top email up by one. If there are fewer than 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 , the number of subcases in this input, all of which must be solved correctly to solve the input case. The subcases then follow. For each subcase, the first line of input contains and . The next line contains .
It is guaranteed that the sum of over all subcases does not exceed , and that the sum of over all subcases does not exceed .
输出格式
Output lines, each one either containing either YES or NO, specifying whether FJ can successfully file all his emails in each of the subcases.
题目大意
题目描述
在整理收件箱方面已经落后了。他的屏幕排列方式是,屏幕左侧有一个垂直的文件夹列表,屏幕右侧有一个垂直的电子邮件列表。共有 个文件夹,编号为 。他的收件箱当前包含 封编号为 的电子邮件;第 封电子邮件需要归档到文件夹 。
的屏幕有些小,所以他同时只能查看 个文件夹和 封电子邮件。最初,他的屏幕左侧显示文件夹 ,右侧显示电子邮件 。要访问其他文件夹和电子邮件,他需要滚动相应的列表。例如,如果他将文件夹列表向下滚动一个位置,他的屏幕将显示文件夹 ,然后再向下滚动一个位置将显示文件夹 。当 将一封电子邮件拖曳至一个文件夹时,该电子邮件将从电子邮件列表中消失,并且消失的电子邮件之后的电子邮件会向上移动一个位置。例如,如果当前显示的是电子邮件 ,然后 将电子邮件 拖曳至其对应的文件夹中,则电子邮件列表现在将显示电子邮件 。 只可以将电子邮件拖曳至其需要归档的文件夹中。
不幸的是, 的鼠标滚轮坏了,所以他只能向下滚动,不能向上滚动。他可以实现类似向上滚动的唯一情况是,他正在查看他的电子邮件列表中的最后 封电子邮件,并且他归档了其中的一封。在这种情况下,电子邮件列表将再继续显示尚未归档的最后 封电子邮件,实际上使得最上方的电子邮件向上滚动了一个位置。如果剩余少于 封电子邮件,则将显示所有电子邮件。
请帮助 判断是否可能归档他的所有电子邮件。
输入格式
输入的第一行包含 ,为当前测试用例中的子测试用例数量,所有子测试用例必须全部正确才能通过当前测试用例。以下是 个子测试用例。每一个子测试用例的第一行包含 , 和 。第二行包含 。
输入保证所有子测试用例的 之和不超过 ,所有子测试用例的 之和不超过 。
输出格式
输出 行,每行包含 "YES" 或 "NO",表示对于 个子测试用例中的每一个, 是否可以成功归档他的所有电子邮件。
数据范围
- 测试点 2-10 中,所有子测试用例的 之和不超过 。
- 测试点 11-12 没有额外限制。
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
提示
【数据范围】
- In inputs 2-10, the sum of over all subcases does not exceed .
- In inputs 11-12, no additional constraints.