VxiaohuanV @ 2022-08-02 10:59:06
#include <bits/stdc++.h>
using namespace std;
#define M 2000005
#define ri register int
int n,m;
int p[M];
int qu[M];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n>>m;
for(ri i=1;i<=n;i++) cin>>p[i];
int l=1,r=1;qu[1]=1;cout<<0<<endl;
for(ri i=2;i<=n;i++)
{
while(qu[l]<i-m) l++;
cout<<p[qu[l]]<<endl;
while(p[qu[r]]>=p[i]&&r>=l) r--;qu[++r]=i;
}
return 0;
}
by _Remake_ @ 2022-08-02 11:01:24
endl很慢(
by _Remake_ @ 2022-08-02 11:02:27
@sfksf 换成"\n"直接过了
by TheSky233 @ 2022-08-02 11:04:23
endl
会刷新缓冲区,比较慢
by bikuhiku @ 2022-08-02 11:15:46
似乎读入
by rxjdasiwzl @ 2022-08-02 12:39:39
@bikuhiku 在我这里读入 std::cin
用时 1.155 s,scanf
用时 1.297 s。