Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
- const long long MOD = 1e9 + 7, OO = 1e18;
- const double PI = acos(-1);
- const int N = 1e6 + 5;
- const int dx[4] = {0, 0, 1, -1};
- const int dy[4] = {1, -1, 0, 0};
- long long t, n, k, a[N];
- int main()
- {
- IO
- // vector<long long>v;
- // for (int i = 0; i < 5; i++)
- // {
- // v.push_back(i);
- // }
- // for (auto &x : v)
- // {
- // x++;
- // }
- // for (auto x : v)
- // {
- // cout << x << ' ';
- // }
- // long long y = 1;
- // long long &x = y;
- // cout << x << ' ' << y << '\n';
- // x++;
- // cout << x << ' ' << y;
- cin >> t;
- while (t--)
- {
- deque<long long>dq;
- long long mx = -OO;
- cin >> n >> k;
- for (int i = 1; i <= n; i++)
- {
- cin >> a[i];
- if (i <= k)
- {
- dq.push_back(a[i]);
- mx = max(mx, a[i]);
- }
- }
- cout << mx << ' ';
- for (int i = 2; i + k - 1 <= n; i++)
- {
- dq.pop_front();
- dq.push_back(a[i + k - 1]);
- mx = -OO;
- for (auto x : dq)
- {
- mx = max(mx, x);
- }
- cout << mx << ' ';
- }
- cout << '\n';
- }
- return 0;
- // auto x = "mahmoud";
- // cout << x;
- }
- // vctor<char>v;
- // x = v[0];
- // x = v[1];
- // x = v[2];
- // x = v[3];
- // x = v[4];
- // for (auto x : v)
- // {
- // }
- /*
- 1 2 -1 4 5
- mx = -OO;
- mx = max(-OO, 1) = 1;
- mx = max(1, 2) = 2
- mx = max(2, -1) = 2
- */
Advertisement
Add Comment
Please, Sign In to add comment