Advertisement
EWTD

Untitled

Oct 26th, 2019
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. //#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
  2. //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
  3. #include <iostream>
  4. #include <vector>
  5. #include <set>
  6. #include <array>
  7. #include <cmath>
  8. #include <algorithm>
  9. #include <map>
  10. using namespace std;
  11. #define MAX_INT 2147483647
  12. #define ll long long
  13. int main(){
  14. int t;
  15. cin >> t;
  16. for(int i = 0; i < t; ++i){
  17. int n,k,d;
  18. int ans = MAX_INT;
  19. cin >> n >> k >> d;
  20. map<int,int> M;
  21. vector<int> vec(n);
  22. for(int j = 0; j < n; ++j){
  23. cin >> vec[j];
  24. }
  25. for(int j = 0; j < d; ++j){
  26. M[vec[j]]++;
  27. }
  28. for(int j = 0; j < n-d+1; ++j) {
  29. ans = min(ans, (int) M.size());
  30. M[vec[j]]--;
  31. if(M[vec[j]] == 0){
  32. M.erase(vec[j]);
  33. }
  34. M[vec[j + d]]++;
  35. }
  36. cout << ans << '\n';
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement