求助:60分

P1440 求m区间内的最小值

CSP_Sept @ 2020-02-13 11:08:14

#include <bits/stdc++.h>
using namespace std;
int tmp,minn,minx,flag=0,n,m,bef;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&tmp);
        if(!flag){
            minn=tmp;
            minx=1;
            flag=1;
        }
        else if(bef<=minn||minx+m<i){//更小或超过则更新
            minn=bef;
            minx=i-1;
        }
        if(i==1) printf("0\n");
        else printf("%d\n",minn);
        bef=tmp;
    }
    return 0;
}

by CSP_Sept @ 2020-02-13 11:30:38

@Asuna_Eternity 谢谢您的帮助!


by Asuna_Eternity @ 2020-02-13 11:31:22

@CSP_Sept 不谢,况且也没有帮到您什么!


上一页 |