32分求调
查看原帖
32分求调
1478840
Zongjixiong楼主2025/1/16 09:03

样例过了,一切正常,但运行只有32分

#include <bits/stdc++.h>
using namespace std;
const int M=1e5+10;
int n,k,a[M];
void pt()
{
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	//pt();
	for(int i=1;i<=n;i++)
	{
		if(a[i]<k)
		{
			a[i]=a[1];
		}
		else if(a[i]>k)
		{
			a[i]=a[n];	
		} 
	}
	pt();
	return 0;
}

2025/1/16 09:03
加载中...