为什么过不了,求调
查看原帖
为什么过不了,求调
725133
gzy0215楼主2023/8/14 08:39
#include<bits/stdc++.h>
using namespace std;
std::deque<unsigned long long int> a;
int main()
{
	int m,n,e[500001],d[500001],h[500001],f[500001],g=0;
	cin>>m>>n;
	for(int i=1;i<=m;i++)
	{
		cin>>e[i];
		a.push_front(e[i]);
	}
	for(int i=1;i<=m;i++)
	{
		if(i+n<=m)
		{
			for(int j=i+n;j<=m;j++)
			{
				g=a.front();
				a.pop_front();
				a.push_back(g);
				g=0;
			}
		}
		for(int o=1;o<=n;o++)
		{
			h[i]=a.front();
		}
		for(int l=1;l<=n;l++)
		{
			if(h[l]>h[l+1]&&h[l]>h[0])
			{
				h[0]=h[l];
				h[n+2]=h[l+1];
			}
		}
		for(int s=1;s<=n;s++)
		{
			a.push_back(h[s]);
		}
		e[i]=h[0];
		d[i]=h[n+2];
	}
	for(int i=1;i<=m-n+1;i++)
	{
		cout<<e[i]<<" ";
	}
	cout<<endl;
	for(int i=1;i<=m-n+1;i++)
	{
		cout<<d[i]<<" ";
	}
	return 0;
}
2023/8/14 08:39
加载中...