CF1225B1.TV Subscriptions (Easy Version)

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The only difference between easy and hard versions is constraints.

The BerTV channel every day broadcasts one episode of one of the kk TV shows. You know the schedule for the next nn days: a sequence of integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤k1 \le a_i \le k), where aia_i is the show, the episode of which will be shown in ii-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 dd (1≤d≤n1 \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 dd consecutive days in which all episodes belong to the purchased shows.

简单版本与困难版本的唯一区别在于约束条件。

BerTV 频道每天播出 kk 部电视剧中某一部的一集。已知接下来 nn 天的播出计划:一个整数序列 a1,a2,…,ana_1, a_2, \dots, a_n(其中 1≤ai≤k1 \le a_i \le k),aia_i 表示第 ii 天将播出的电视剧编号。

每部电视剧的订阅服务需为整部剧(即其所有剧集)单独购买,不同剧集的订阅相互独立。

为了能够连续 dd(1≤d≤n1 \le d \le n)天观看所订阅剧集的剧集,你至少需要购买多少部电视剧的订阅?换言之,你需要购买最少数量的电视剧,使得存在某个长度为 dd 的连续天数区间,该区间内每一天播出的剧集均属于你已订阅的剧集。

输入格式

The first line contains an integer tt (1≤t≤1001 \le t \le 100) — the number of test cases in the input. Then tt test case descriptions follow.

The first line of each test case contains three integers n,kn, k and dd (1≤n≤1001 \le n \le 100, 1≤k≤1001 \le k \le 100, 1≤d≤n1 \le d \le n). The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤k1 \le a_i \le k), where aia_i is the show that is broadcasted on the ii-th day.

It is guaranteed that the sum of the values of nn for all test cases in the input does not exceed 100100.

第一行包含一个整数 tt(1≤t≤1001 \le t \le 100),表示输入中测试用例的数量。随后是 tt 个测试用例的描述。

每个测试用例的第一行包含三个整数 n,kn, k 和 dd(1≤n≤1001 \le n \le 100,1≤k≤1001 \le k \le 100,1≤d≤n1 \le d \le n)。第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤k1 \le a_i \le k),其中 aia_i 表示第 ii 天播出的节目。

保证输入中所有测试用例的 nn 值之和不超过 100100。

输出格式

Print tt 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 dd consecutive days. Please note that it is permissible that you will be able to watch more than dd days in a row.

输出 tt 个整数——即按输入中测试用例的顺序给出的答案。每个测试用例的答案为:为确保能在 BerTV 上连续 dd 天观看所购电视节目的剧集,所需购买订阅的电视节目数量的最小值。请注意,你可能能够连续观看超过 dd 天。

输入输出样例

  • 输入#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 11 and on show 22. 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,93,5,7,8,9, and you will be able to watch shows for the last eight days.

在第一个测试用例中,为了有机会连续两天观看节目,你需要购买节目 11 和节目 22 的订阅。因此答案为 22。

在第二个测试用例中,你可以购买任意一个节目的订阅,因为对每个节目,都存在一个仅由该节目的剧集组成的、长度为三天的连续时间段。

在第三个测试用例中,在唯一的一个四天时间段内,你拥有四个不同的节目,因此你需要购买这四个节目的全部订阅。

在第四个测试用例中,你可以购买节目 3,5,7,8,93,5,7,8,9 的订阅,从而能够观看最后八天的节目。

输入解题思路,AI测评打分。不知道怎么写?

首页