A12929 | TV Subscriptions (Easy Version)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The only difference between easy and hard versions is constraints.
The BerTV channel every day broadcasts one episode of one of the $k$ TV shows. You know the schedule for the next $n$ days: a sequence of integers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le k$ ), where $a_i$ is the show, the episode of which will be shown in $i$ -th day.
The subscription to the show is bought for the entire show (i.e. for all its episodes), for each show the subscription is bought separately.
How many minimum subscriptions do you need to buy in order to have the opportunity to watch episodes of purchased shows $d$ ( $1 \le d \le n$ ) days in a row? In other words, you want to buy the minimum number of TV shows so that there is some segment of $d$ consecutive days in which all episodes belong to the purchased shows.
The BerTV channel every day broadcasts one episode of one of the $k$ TV shows. You know the schedule for the next $n$ days: a sequence of integers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le k$ ), where $a_i$ is the show, the episode of which will be shown in $i$ -th day.
The subscription to the show is bought for the entire show (i.e. for all its episodes), for each show the subscription is bought separately.
How many minimum subscriptions do you need to buy in order to have the opportunity to watch episodes of purchased shows $d$ ( $1 \le d \le n$ ) days in a row? In other words, you want to buy the minimum number of TV shows so that there is some segment of $d$ consecutive days in which all episodes belong to the purchased shows.
输入格式
The first line contains an integer $t$ ( $1 \le t \le 100$ ) — the number of test cases in the input. Then $t$ test case descriptions follow.
The first line of each test case contains three integers $n, k$ and $d$ ( $1 \le n \le 100$ , $1 \le k \le 100$ , $1 \le d \le n$ ). The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le k$ ), where $a_i$ is the show that is broadcasted on the $i$ -th day.
It is guaranteed that the sum of the values of $n$ for all test cases in the input does not exceed $100$ .
The first line of each test case contains three integers $n, k$ and $d$ ( $1 \le n \le 100$ , $1 \le k \le 100$ , $1 \le d \le n$ ). The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le k$ ), where $a_i$ is the show that is broadcasted on the $i$ -th day.
It is guaranteed that the sum of the values of $n$ for all test cases in the input does not exceed $100$ .
输出格式
Print $t$ integers — the answers to the test cases in the input in the order they follow. The answer to a test case is the minimum number of TV shows for which you need to purchase a subscription so that you can watch episodes of the purchased TV shows on BerTV for $d$ consecutive days. Please note that it is permissible that you will be able to watch more than $d$ days in a row.
输入输出样例
输入 #1
4 5 2 2 1 2 1 2 1 9 3 3 3 3 3 2 2 2 1 1 1 4 10 4 10 8 6 4 16 9 8 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
输出 #1
2 1 4 5
In the first test case to have an opportunity to watch shows for two consecutive days, you need to buy a subscription on show $1$ and on show $2$ . So the answer is two.
In the second test case, you can buy a subscription to any show because for each show you can find a segment of three consecutive days, consisting only of episodes of this show.
In the third test case in the unique segment of four days, you have four different shows, so you need to buy a subscription to all these four shows.
In the fourth test case, you can buy subscriptions to shows $3,5,7,8,9$ , and you will be able to watch shows for the last eight days.
In the second test case, you can buy a subscription to any show because for each show you can find a segment of three consecutive days, consisting only of episodes of this show.
In the third test case in the unique segment of four days, you have four different shows, so you need to buy a subscription to all these four shows.
In the fourth test case, you can buy subscriptions to shows $3,5,7,8,9$ , and you will be able to watch shows for the last eight days.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted