fork download
  1. /*
  2.  
  3.   F U Z U M I T A K A H A S H I -w-
  4.  
  5. */
  6. #include <bits/stdc++.h>
  7.  
  8. using namespace std;
  9.  
  10. int n, m;
  11. map<int, int> mp;
  12.  
  13. signed main(){
  14. cin >>n >>m;
  15. int a[n + 1];
  16. for (int i = 1; i < m; ++i){
  17. cin >>a[i];
  18. ++mp[a[i]];
  19. }
  20. for (int i = m; i <= n; ++i){
  21. cin >>a[i]; ++mp[a[i]];
  22. cout <<mp.begin() -> first <<' ';
  23. if (--mp[a[i - m + 1]] == 0) mp.erase(a[i - m + 1]);
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0s 5304KB
stdin
10 6
16 61 18 55 68 60 57 43 10 37 
stdout
16 18 18 10 10