Starduster @ 2018-05-04 09:50:02
求助
#include<bits/stdc++.h>
using namespace std;
int dp[2000010][21];
int n,m;
inline void init();
inline int ask(int,int);
inline int getint();
inline double lg(double);
int main(int argc,char **argv){
n=getint(),m=getint();
for(register int i(1);i<=n;++i)dp[i][0]=getint();
init();
puts("0");
for(register int i(2);i<=n;++i){
printf("%d\n",ask(i-m<=0?1:i-m,i-1));
}
return 0;
}
inline int getint(){
register int ret(0);
register char ch(getchar());
while(ch<'0'||ch>'9')ch=getchar();
while(ch>='0'&&ch<='9')ret=ret*10+ch-'0',ch=getchar();
return ret;
}
inline void init(){
for(register int j(1);j<21;++j){
for(register int i(1);i<=n;++i){
if(i+(1<<j)-1<=n){
dp[i][j]=min(dp[i][j-1],dp[i+(1<<(j-1))][j-1]);
}
}
}
}
inline double lg(double num){
return log(num)/log(2.0);
}
inline int ask(int l,int r){
register int x((int)(lg((double)(r-l+1))));
return min(dp[l][x],dp[r+1-(1<<x)][x]);
}
by 薛裕龙 @ 2018-05-04 09:53:37
大佬大佬
by 薛裕龙 @ 2018-05-04 09:57:30
我ST,TLE*3,*WA1**???…………
by Starduster @ 2018-05-04 11:49:13
@xueyulong 现在双MLE咋办
by 薛裕龙 @ 2018-05-04 14:47:07
@the_Miracle 扩大j范围,然后做时间优化
by Starduster @ 2018-05-04 15:00:03
@xueyulong 我不需要优化时间啊我需要优化内存
by 薛裕龙 @ 2018-05-04 17:11:16
@the_Miracle 但是我j用23是MLE,24就是TLE,吼迷
by Legends丶dream @ 2018-07-16 20:19:30
我ST两MLE
by PBCWZCC @ 2018-08-18 11:01:20
这题