Mahmoud_Hawara

Untitled

Mar 13th, 2022
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  4. const long long N = 2e5 + 5, MOD = 1e9 + 7, OO = 1e18;
  5. const double PI = acos(-1);
  6. const int dx[4] = {0, 0, 1, -1};
  7. const int dy[4] = {1, -1, 0, 0};
  8.  
  9. long long t, n, k, a[N];
  10.  
  11. int main() {
  12.     IO
  13.     cin >> t;
  14.     while (t--) {
  15.         cin >> n >> k;
  16.         for (int i = 1; i <= n; i++)cin >> a[i];
  17.         deque<long long>dq;
  18.         for (int i = 1; i < k; i++)dq.push_back(a[i]);
  19.         dq.push_front(0LL);
  20.         for (int i = k; i <= n; i++) {
  21.             dq.pop_front();
  22.             dq.push_back(a[i]);
  23.             cout << *max_element(dq.begin(), dq.end()) << ' ';
  24.         }
  25.         cout << '\n';
  26.     }
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment