2个点TLE
查看原帖
2个点TLE
781438
threebody_santi楼主2024/6/12 17:50
#include<bits/stdc++.h>
using namespace std;
deque<int> q;
int a[41000000];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
	}
	cout<<"0"<<endl;
	for(int i=2;i<=n;i++)
	{
		while(!q.empty() && a[q.back()]>=a[i-1])
		{
			q.pop_back();
		}
		q.push_back(i-1);
		while(!q.empty() && q.back()-q.front()+1>k)
		{
			q.pop_front();
		}
	/*	for(auto j:q)
		{
			cout<<a[j]<<" ";
		}*/
		cout<<a[q.front()]<<endl;
	}
    return 0;
}

2个点TLE,有没有大佬修改亿下

2024/6/12 17:50
加载中...