A858 | Email Filing--Silver
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
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 $M$
total folders, numbered $1 \ldots M$ ($1 \le M \le 10^4)$. His inbox currently
contains $N$ emails numbered $1\ldots N$ ($1 \le N \le 10^5$); the $i$th email
needs to be filed into folder $f_i$ ($1\le f_i\le M$).
FJ's screen is rather small, so he can only view $K$ ($1\le K\le \min(N,M)$)
folders and $K$ emails at once. Initially, his screen starts out displaying
folders $1 \ldots K$ on the left and emails $1 \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 \ldots K+1$, and then scrolling down one
position further it will display folders $3 \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, 5$ are currently displayed and FJ drags email 3 into its
appropriate folder, the email list will now show emails $1, 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 $K$ emails in his email
list, and he files one of these. In this case, the email list will again show
the last $K$ emails that haven't yet been filed, effectively scrolling the top
email up by one. If there are fewer than $K$ emails remaining, then all of
them will be displayed.
Please help FJ determine if it is possible to file all of his emails.
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 $M$
total folders, numbered $1 \ldots M$ ($1 \le M \le 10^4)$. His inbox currently
contains $N$ emails numbered $1\ldots N$ ($1 \le N \le 10^5$); the $i$th email
needs to be filed into folder $f_i$ ($1\le f_i\le M$).
FJ's screen is rather small, so he can only view $K$ ($1\le K\le \min(N,M)$)
folders and $K$ emails at once. Initially, his screen starts out displaying
folders $1 \ldots K$ on the left and emails $1 \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 \ldots K+1$, and then scrolling down one
position further it will display folders $3 \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, 5$ are currently displayed and FJ drags email 3 into its
appropriate folder, the email list will now show emails $1, 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 $K$ emails in his email
list, and he files one of these. In this case, the email list will again show
the last $K$ emails that haven't yet been filed, effectively scrolling the top
email up by one. If there are fewer than $K$ 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 $T$ ($1 \le T \le 10$), the number of
subcases in this input, all of which must be solved correctly to solve the
input case. The $T$ subcases then follow. For each subcase, the first line of
input contains $M$, $N$, and $K$. The next line contains $f_1 \ldots f_N$.
It is guaranteed that the sum of $M$ over all subcases does not exceed $10^4$,
and that the sum of $N$ over all subcases does not exceed $10^5$.
subcases in this input, all of which must be solved correctly to solve the
input case. The $T$ subcases then follow. For each subcase, the first line of
input contains $M$, $N$, and $K$. The next line contains $f_1 \ldots f_N$.
It is guaranteed that the sum of $M$ over all subcases does not exceed $10^4$,
and that the sum of $N$ over all subcases does not exceed $10^5$.
输出格式
Output $T$ lines, each one either containing either YES or NO, specifying
whether FJ can successfully file all his emails in each of the $T$ subcases.
whether FJ can successfully file all his emails in each of the $T$ subcases.
输入输出样例
输入 #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
输出 #1
YES YES NO YES YES NO
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted