#include<stdio.h>//每次要吧生命值长的加入,吧生命用光的舍弃 #define N 1100000 int getmin[N],getmax[N],num[N],n,k,a[N]; int main(){ int i,first,last; while(scanf("%d%d",&n,&k)!=EOF) { for(i=1;i<=n;i++) scanf("%d",&a[i]); first=1;last=…
题目链接:https://www.luogu.org/problem/P1886#submit 题意:给定n个数,求大小为k的滑动窗口中最小值和最大值. 思路:单调队列模板题. AC代码: #include<cstdio> #include<algorithm> using namespace std; ; int n,k,head,tail; int a[maxn],q[maxn],p[maxn]; int main(){ scanf("%d%d",&…
题面: An array of size n ≤ 106 is given to you. There is a sliding window of size k which 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 po…
思路:裸的单调队列. #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #define Maxn 1000010 using namespace std; int n,k,que[Maxn],num[Maxn],head,rear; int main() { int i,j,a; while(scanf("%d%d",&n,&…