Advertisement
Mahmoud_Hawara

Untitled

Mar 13th, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 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.         for (int i = 1; i <= n - k + 1; i++) {
  18.             long long mx = -OO;
  19.             for (int j = i; j <= i + k - 1; j++) {
  20.                 mx = max(mx, a[j]);
  21.             }
  22.             cout << mx << ' ';
  23.         }
  24.         cout << '\n';
  25.     }
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement