st表版子题
#include#include #include #include #include #include #define MAXN 1000005using namespace std;int dp[MAXN][25],i,N,M;inline void build(){ for(int j = 1;j <= 20;++j) { for(i = 1;i <= M;++i) if(i+(1< <=M) dp[i][j]=min(dp[i][j-1],dp[i+(1<<(j-1))][j-1]); }}int main(){ scanf("%d%d",&M,&N); for(i=1;i<=M;++i) scanf("%d",&dp[i][0]); build(); for(int op = 1;op <= M-N+1;++op){ int k=log2(N); printf("%d\n",min(dp[op][k],dp[op+N-1-(1<