题面 单调队列模板题. 单调队列可以从队首和队尾出队. 队列中的元素大小具有一定的顺序. 具体可参考这一篇题解 #include <bits/stdc++.h> #define itn int #define gI gi using namespace std; inline int gi() { int f = 1, x = 0; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') f = -1; c = g…
#include <iostream> #include <cstdio> using namespace std; int n,k,a[1000007],q1[2000007],q2[2000007],ans1[1000007],ans2[1000007]; int main(){ while(~scanf("%d%d",&n,&k)){ int i; for(i=1;i<=n;++i) scanf("%d",a+i)…
An array of size n ≤ 10 6 is given to you. There is a sliding window of size kwhich is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves rightwards by one positi…