心态裂开,调了半天还是WA

P1440 求m区间内的最小值

pencil @ 2021-12-01 17:38:44

RT

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;
typedef long long ll;
const int N=100000010;
ll read(){
    char a=getchar();
    ll qwq=0;
    while(a<'0'||a>'9')
    a=getchar();
    while(a>='0'&&a<='9'){
        qwq*=10;
        qwq+=a-'0';
        a=getchar();
    }
    return qwq;
}
int a[1000010],q[1000010];
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int h=0,t=1;
    for(int i=0;i<n;i++){
        while(h<=t&&q[h]+k<=i) h++;
        while(h<=t&&a[q[t]]>=a[i]) t--;
        q[++t]=i;
//      if(i-k>=0){
            cout<<a[q[h]]<<" ";
//      }
//      cout<<a[head]<<" ";
    }
    return 0;
} 
//2 10 9
//a^b mod p=s
//6 123 321 666 456 321 654

|