贪心 Codeforces Round #301 (Div. 2) B. School Marks

时间:2023-03-09 00:19:34
贪心 Codeforces Round #301 (Div. 2) B. School Marks

题目传送门

 /*
贪心:首先要注意,y是中位数的要求;先把其他的都设置为1,那么最多有(n-1)/2个比y小的,cnt记录比y小的个数
num1是输出的1的个数,numy是除此之外的数都为y,此时的numy是最少需要的,这样才可能中位数大于等于y
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std; const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
int a[MAXN]; int main(void) //Codeforces Round #301 (Div. 2) B. School Marks
{
//freopen ("B.in", "r", stdin); int n, k, p, x, y;
while (scanf ("%d%d%d%d%d", &n, &k, &p, &x, &y) == )
{
int sum = , cnt = ;
for (int i=; i<=k; ++i)
{
scanf ("%d", &a[i]); sum += a[i];
if (a[i] < y) cnt++;
} if (cnt <= n / )
{
int num1 = min (n / - cnt, n - k);
int numy = n - k - num1; sum += num1 + numy * y;
if (sum > x) puts ("-1");
else
{
for (int i=; i<=num1; ++i) printf ("%d%c", , (numy== && i==num1) ? '\n' : ' ');
for (int i=; i<=numy; ++i) printf ("%d%c", y, (i==numy) ? '\n' : ' ');
}
}
else puts ("-1");
} return ;
}