题意:
这是在选美比赛吗?面试官要求每天面试的漂亮指数不能够相同,给出 k 天的方案。
思路:
每次选择出最大的几个(1,2,3…),然后在剩下的随机选就可以了
AC CODE:
#include<stdio.h>
#include<cstring>
#include<algorithm>
#define HardBoy main()
#define ForMyLove return 0;
using namespace std;
const int MYDD = 1103;
int a[MYDD];
int HardBoy {
int n, k;//, a[MYDD];
scanf("%d %d", &n, &k);
for(int j = 1; j <= n; j++) {
scanf("%d", &a[j]);
}
// BUG-> 漏掉取地址符
int day = 0;
sort(a+1, a+1+n);
for (int i = 1; i <= n; i++)
for (int j = n-i+1; j >= 1; j--) {
day++;
if (day > k) break;
printf("%d ", i);
for (int l = n; l > n-i+1; l--)
printf("%d ", a[l]);
printf("%d\n", a[j]);
}
ForMyLove
}