BZHZS @ 2021-07-21 23:55:55
#include <bits/stdc++.h>
#define ll long long
#define yes {puts("Yes");return 0;}
#define no {puts("No");return 0;}
#define BZHZS puts("BZH is a handsome boy.");
using namespace std;
struct node {
int sum, id;
};
node a[2000006];
deque <node> q, w;
int n, k;
int ans1[2000006], ans2[2000006];
void ts (int a, string tt) {
cout << tt << ":: " << a << endl;
system ("pause");
return;
}
int main() {
ios:: sync_with_stdio (0);
cin.tie(0), cout.tie(0);
//freopen ("BZHZS.in" , "r" , stdin);
//freopen ("BZHZS.out " , "w" , stdout);
cin >> n >> k;
for (int i=1; i<=n; i++) {
cin >> a[i].sum;
a[i].id = i;
}
cout << 0 << endl;
for (int i=1; i<n; i++) {
while (!w.empty() && w.back().sum>=a[i].sum) {
w.pop_back();
}
w.push_back (a[i]);
if (w.front().id == i-k) {
w.pop_front();
}
cout << w.front().sum << endl;
}
return 0;
}
by ker_xyxyxyx_xxs @ 2021-07-22 00:41:01
@BZHZS 建议线段树(我明天再写
by 鲁锦聪 @ 2021-07-22 16:28:45
你把system ("pause");删了试试,不然可能会卡住
by Shunpower @ 2021-10-18 19:26:38
请使用快读快输