欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1225B1.TV Subscriptions (Easy Version)
TV Subscriptions (Easy Version)
The only difference between easy and hard versions is constraints.
The BerTV channel every day broadcasts one episode of one of the TV shows. You know the schedule for the next days: a sequence of integers (), where is the show, the episode of which will be shown in -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 () days in a row? In other words, you want to buy the minimum number of TV shows so that there is some segment of consecutive days in which all episodes belong to the purchased shows.
Input
The first line contains an integer () — the number of test cases in the input. Then test case descriptions follow.
The first line of each test case contains three integers and (, , ). The second line contains integers (), where is the show that is broadcasted on the -th day.
It is guaranteed that the sum of the values of for all test cases in the input does not exceed .
Output
Print 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 consecutive days. Please note that it is permissible that you will be able to watch more than days in a row.
Note
In the first test case to have an opportunity to watch shows for two consecutive days, you need to buy a subscription on show and on show . 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 , and you will be able to watch shows for the last eight days.
Samples
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
2
1
4
5
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |