肿么感觉自己最近越来越懒了。。。
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define M 1001000
int n,k;
typedef struct abcd{int num,pos;}abcd;abcd empty;
typedef struct monotonous_increasing_queue{
abcd queue[M];int h,r;
void insert(int num,int pos)
{
while(queue[h].num>num&&r!=h)queue[h--]=empty;
queue[++h].num=num;queue[h].pos=pos;
if(queue[r+1].pos<=pos-k)queue[++r]=empty;
}
}monotonous_increasing_queue;
monotonous_increasing_queue q;
typedef struct monotonous_decreasing_queue{
abcd queue[M];int h,r;
void insert(int num,int pos)
{
while(queue[h].num<num&&r!=h)queue[h--]=empty;
queue[++h].num=num;queue[h].pos=pos;
if(queue[r+1].pos<=pos-k)queue[++r]=empty;
}
}monotonous_decreasing_queue;