stswkl @ 2022-06-18 19:20:52
#include<bits/stdc++.h>
using namespace std;
long long n,m,x[2000005],t;
map<long long,long long>a;
int main()
{
scanf("%lld%lld",&n,&m);
for(int i=1;i<=n;i++)
{
scanf("%lld",&x[i]);
if(i>m+1)
{
t=x[i-m-1];
a[t]--;
if(a[t]==0)a.erase(t);
}
if(i==1)printf("0\n");
else printf("%lld\n",a.begin()->first);
a[x[i]]++;
}
return 0;
}
开了
by 天命之路 @ 2022-06-18 19:31:00
map 显然会 T
得换单调队列啊
by stswkl @ 2022-06-18 19:53:58
@天命之路 map为什么会超时?
by 红黑树 @ 2022-06-18 20:04:11
@stswkl map 单次操作复杂度是
by stswkl @ 2022-06-18 20:16:10
@红黑树 3Q