思路:裸的单调队列. #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,&…
#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=…
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…
Cut the Sequence Time Limit: 2000MS Memory Limit: 131072K Total Submissions: 8764 Accepted: 2576 Description Given an integer sequence { an } of length N, you are to cut the sequence into several parts every one of which is a consecutive subseque…