zhibuba @ 2020-07-26 14:04:24
#include <iostream>
#include <queue>
using namespace std;
using T = pair<int, int>;
priority_queue<T, vector<T>, greater<T>> Q;
int main()
{
cin.sync_with_stdio(false), cout.sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
if (i == 1)
cout << 0 << '\n';
else
{
while (Q.top().second < i - m)
Q.pop();
cout << Q.top().first << '\n';
}
int a;
cin >> a;
Q.push({a, i});
}
return 0;
}
by IntrepidStrayer @ 2020-07-26 14:06:20
用单调队列
by Infinempty @ 2020-07-26 14:11:02
这道题是滑动窗口模型吧,和堆好像没有太大关联
by 倒草人 @ 2020-09-13 22:19:44
Q-Q70分,就因为我用cin,用scanf就过了。。。。
by 倒草人 @ 2020-09-13 22:21:07
不过我写的是单调数列