有什么问题?样例没过但有28分,求调
查看原帖
有什么问题?样例没过但有28分,求调
1453183
hzy0928楼主2025/1/18 10:58
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
	int n,k;
	cin >> n >> k;
	int Max = -100001;
	int Min = 100001;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		Max = max(Max , a[i]);
		Min = min(Max , a[i]);
	}
	for (int i = 0; i < n; i++) {
		if (a[i] > k) {
			a[i] = Max;
		}
		if (a[i] < k) {
			a[i] = Min;
		}
		cout << a[i] << " ";
	}

	return 0;
}
2025/1/18 10:58
加载中...