蒟蒻80求助

P1440 求m区间内的最小值

KevinYu @ 2018-10-21 15:22:24

RT,#3,#7 WA

#include<cstring>
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<queue>
#include<vector>
#include<complex>
using namespace std;
struct node
{
    int val,id;
    node(){}
    node(int val,int id):val(val),id(id){}
}a[2000020];
int n,m,head(1),tail(1);
int t;
int main()
{
    int *p1=&a[1].val;
    int *p2=&a[1].id;
    scanf("%d%d",&n,&m);
    printf("0\n");
    scanf("%d",p1);
    tail++;
    for(int i=2;i<n+1;i++)
    {
        if(i-*(p2+2*head-2)>m)head++;
        printf("%d\n",*(p1+2*head-2));
        scanf("%d",&t);
        while(tail>head&&t<*(p1+tail*2-4))tail--;
        *(p1+tail*2-2)=t;*(p2+tail*2-2)=i;
        tail++;
    }
    return 0;
}

|