Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
- //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
- #include <iostream>
- #include <vector>
- #include <set>
- #include <array>
- #include <cmath>
- #include <algorithm>
- #include <map>
- using namespace std;
- #define MAX_INT 2147483647
- #define ll long long
- int main(){
- int t;
- cin >> t;
- for(int i = 0; i < t; ++i){
- int n,k,d;
- int ans = MAX_INT;
- cin >> n >> k >> d;
- map<int,int> M;
- vector<int> vec(n);
- for(int j = 0; j < n; ++j){
- cin >> vec[j];
- }
- for(int j = 0; j < d; ++j){
- M[vec[j]]++;
- }
- for(int j = 0; j < n-d+1; ++j) {
- ans = min(ans, (int) M.size());
- M[vec[j]]--;
- if(M[vec[j]] == 0){
- M.erase(vec[j]);
- }
- M[vec[j + d]]++;
- }
- cout << ans << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement