Advertisement
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 N = 2e5 + 5, MOD = 1e9 + 7, OO = 1e18;
- const double PI = acos(-1);
- 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
- cin >> t;
- while (t--) {
- cin >> n >> k;
- for (int i = 1; i <= n; i++)cin >> a[i];
- deque<long long>dq;
- map<long long, long long, greater<long long>>mp;
- for (int i = 1; i < k; i++) {
- dq.push_back(a[i]);
- mp[a[i]]++;
- }
- dq.push_front(0LL);
- mp[0LL]++;
- for (int i = k; i <= n; i++) {
- mp[dq.front()]--;
- if (mp[dq.front()] == 0)mp.erase(dq.front());
- dq.pop_front();
- dq.push_back(a[i]);
- mp[a[i]]++;
- cout << mp.begin()->first << ' ';
- }
- cout << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement