#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=…
思路:裸的单调队列. #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,&…
题目链接: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",&…
Sliding Window Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 67218 Accepted: 19088 Case Time Limit: 5000MS Description An array of size n ≤ 106 is given to you. There is a sliding window of size k which is moving from the very lef…
Sliding Window Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 55309 Accepted: 15911 Case Time Limit: 5000MS Description 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…
最近BZOJ炸了,而我的博客上又更新了一些基本知识,所以这里刷一些裸题,用以丰富知识性博客 POJ2823 滑动的窗口 这是一道经典的单调队题,我记得我刚学的时候就是用这道题作为单调队列的例题,算一道比较基本的题目 先贴题目 Description 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 arr…