智乃的分差(未测)

测评链接https://ac.nowcoder.com/acm/contest/20110

#include <bits/stdc++.h>
using namespace std;
int a[100000005], b[100000005];

bool pai(int a, int b) {
return a > b;
}

int main() {
int T, N, x;

cin >> T;
//scanf("%d",&T);
while (T > 0) {
int max = 0, mi = 0;
memset(b, 0, sizeof(b));
scanf("%d%d", &N, &x);
for (int i = 0; i < N; i++) {
scanf("%d", &a[i]);
b[a[i]]++;
if (b[a[i]] > max) {
max = b[a[i]];
mi = a[i];
}
}
if (x > 0) {
sort(a, a + N, pai);
cout << "yes" << endl;
for (int i = 0; i < N; i++) {
cout << a[i] << ' ';
}
cout << endl;
} else if (x < 0) {
sort(a, a + N);
cout << "yes" << endl;
for (int i = 0; i < N; i++) {
cout << a[i] << ' ';
}
cout << endl;
} else if (2 * max > N) {
cout << "no" << endl;
cout << endl;
} else {
cout << "yes" << endl;
for (int i = 0; i < N; i++) {
cout << a[i] << ' ';
}
cout << endl;
}
T--;
}
return 0;
}

posted @ 2022-10-04 16:16  螃蟹x  阅读(18)  评论(0)    收藏  举报