chenglinyu @ 2023-09-27 21:28:24
#include <bits/stdc++.h>
using namespace std;
#define ios \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define mian main
#define pii pair<int, int>
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e5 + 100;
const int mod = 1e9 + 7;
int n, m, k, t;
ll res, ans, cnt;
template <typename type>
inline void read(type& x)
{
x = 0;
bool flag(0);
char ch = getchar();
while (!isdigit(ch))
flag = ch == '-', ch = getchar();
while (isdigit(ch))
x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
flag ? x = -x : 0;
}
void solve()
{
read(n), read(k);
vector<int> a(n + 1);
vector<int> p[3];
priority_queue<pii, vector<pii>, less<pii>> vx;
priority_queue<pii, vector<pii>, greater<pii>> vn;
for (int i = 1; i <= n; i++)
read(a[i]);
for (int i = 1; i <= n; i++) {
vn.emplace(make_pair(a[i], i));
vx.emplace(make_pair(a[i], i));
if (i >= k) {
while (vn.top().second <= i - k)
vn.pop();
while (vx.top().second <= i - k)
vx.pop();
p[1].push_back(vn.top().first);
p[2].push_back(vx.top().first);
}
}
for (int i = 1; i <= 2; i++) {
for (auto ii : p[i])
cout << ii << ' ';
cout << '\n';
}
}
int mian()
{
ios;
int T = 1;
while (T--) {
solve();
}
return 0;
}
by zuohan @ 2023-09-27 21:29:45
数组开小了
by ZSB00000 @ 2023-11-18 11:43:42