B. School Marks
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Little Vova studies programming in an elite school. Vova and his classmates are supposed to write n progress tests, for each test they will get a mark from 1 to p. Vova is very smart and he can write every test for any mark, but he doesn't want to stand out from the crowd too much. If the sum of his marks for all tests exceeds value x, then his classmates notice how smart he is and start distracting him asking to let them copy his homework. And if the median of his marks will be lower than y points (the definition of a median is given in the notes), then his mom will decide that he gets too many bad marks and forbid him to play computer games.

Vova has already wrote k tests and got marks a1, ..., ak. He doesn't want to get into the first or the second situation described above and now he needs to determine which marks he needs to get for the remaining tests. Help him do that.

Input

The first line contains 5 space-separated integers: nkpx and y (1 ≤ n ≤ 999, n is odd, 0 ≤ k < n, 1 ≤ p ≤ 1000, n ≤ x ≤ n·p,1 ≤ y ≤ p). Here n is the number of tests that Vova is planned to write, k is the number of tests he has already written, p is the maximum possible mark for a test, x is the maximum total number of points so that the classmates don't yet disturb Vova, y is the minimum median point so that mom still lets him play computer games.

The second line contains k space-separated integers: a1, ..., ak (1 ≤ ai ≤ p) — the marks that Vova got for the tests he has already written.

Output

If Vova cannot achieve the desired result, print "-1".

Otherwise, print n - k space-separated integers — the marks that Vova should get for the remaining tests. If there are multiple possible solutions, print any of them.

Sample test(s)
input
5 3 5 18 4
3 5 4
output
4 1
input
5 3 5 16 4
5 5 5
output
-1
Note

The median of sequence a1, ..., an where n is odd (in this problem n is always odd) is the element staying on (n + 1) / 2 position in the sorted list of ai.

In the first sample the sum of marks equals 3 + 5 + 4 + 4 + 1 = 17, what doesn't exceed 18, that means that Vova won't be disturbed by his classmates. And the median point of the sequence {1, 3, 4, 4, 5} equals to 4, that isn't less than 4, so his mom lets him play computer games.

Please note that you do not have to maximize the sum of marks or the median mark. Any of the answers: "4 2", "2 4", "5 1", "1 5", "4 1", "1 4" for the first test is correct.

In the second sample Vova got three '5' marks, so even if he gets two '1' marks, the sum of marks will be 17, that is more than the required value of 16. So, the answer to this test is "-1".

题目大意:

n是n次测试

k是已经考试了k 次

p是最高分数(这题中没有用)

x是n次总成绩的总和

y是这几次成绩的中数

求在剩下的几次测试中,vova都应该考多少分才能满足x和y.(随意的序列都可以)

分析:

根据题目中所说的  至少有(n+1)/2次要>=y

所以我们就先补y然后剩下的全部是1   这样加起来是最小的   如果他还是大与x说明不能满足

如果把剩下的都补成y还是不够(n+1)/2的话也是不能满足的。

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<queue> using namespace std;
#define N 1050
int main()
{
int n,k,p,x,y,a[N],i;
while(scanf("%d %d %d %d %d",&n,&k,&p,&x,&y)!=EOF)
{
int Y=,sum=;
for(i=;i<=k;i++)
{
scanf("%d",&a[i]);
if(a[i]>=y)
Y++;
sum+=a[i];
}
Y=(n+)/-Y;
if(Y<=)
Y=;
int X=n-Y-k;
if(X<=)
X=;
if((sum+Y*y+X)>x || Y>(n-k))
{
printf("-1\n");
}
else
{
for(i=;i<Y;i++)
printf("%d%c",y,(x== && i==y-)?'\n':' ');
for(i=;i<X;i++)
printf("1%c",i==X-?'\n':' ');
}
}
return ;
}

School Marks-CodeForces的更多相关文章

  1. 2021.5.22 vj补题

    A - Marks CodeForces - 152A 题意:给出一个学生人数n,每个学生的m个学科成绩(成绩从1到9)没有空格排列给出.在每科中都有成绩最好的人或者并列,求出最好成绩的人数 思路:求 ...

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

    题目传送门 /* 贪心:首先要注意,y是中位数的要求:先把其他的都设置为1,那么最多有(n-1)/2个比y小的,cnt记录比y小的个数 num1是输出的1的个数,numy是除此之外的数都为y,此时的n ...

  3. CodeForces 540B School Marks

    http://codeforces.com/problemset/problem/540/B School Marks Time Limit:2000MS     Memory Limit:26214 ...

  4. Codeforces Round #301 (Div. 2) B. School Marks 构造/贪心

    B. School Marks Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/probl ...

  5. codeforces 540B.School Marks 解题报告

    题目链接:http://codeforces.com/problemset/problem/540/B 题目意思:给出 k 个test的成绩,要凑剩下的 n-k个test的成绩,使得最终的n个test ...

  6. (CodeForces )540B School Marks 贪心 (中位数)

    Little Vova studies programming to p. Vova is very smart and he can write every test for any mark, b ...

  7. CodeForces 540B School Marks(思维)

    B. School Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  8. 「日常训练」School Marks(Codeforces Round 301 Div.2 B)

    题意与分析(CodeForces 540B) 题意大概是这样的,有一个考试鬼才能够随心所欲的控制自己的考试分数,但是有两个限制,第一总分不能超过一个数,不然就会被班里学生群嘲:第二分数的中位数(科目数 ...

  9. CodeForces - 540B School Marks —— 贪心

    题目链接:https://vjudge.net/contest/226823#problem/B Little Vova studies programming in an elite school. ...

  10. 【Codeforces Round #424 (Div. 2) C】Jury Marks

    [Link]:http://codeforces.com/contest/831/problem/C [Description] 有一个人参加一个比赛; 他一开始有一个初始分数x; 有k个评委要依次对 ...

随机推荐

  1. Effective Java读书笔记完结啦

    Effective Java是一本经典的书, 很实用的Java进阶读物, 提供了各个方面的best practices. 最近终于做完了Effective Java的读书笔记, 发布出来与大家共享. ...

  2. 【intellij idea】汇总

    1 右键无法创建,找不到scala class https://blog.csdn.net/u011513853/article/details/52896230 2 缩进 https://jingy ...

  3. iOS--多线程之线程间通讯

    线程间通讯 一.NSThread 1.简单说明 ①线程间通信:在1个进程中,线程往往不是孤立存在的,多个线程之间需要经常进行通信 ②线程间通信的体现 1个线程传递数据给另1个线程 在1个线程中执行完特 ...

  4. workstation服务丢失 共享打不开 0x80070035

    这个问题困扰一个星期了,希望能帮到人.

  5. CAD参数绘制线型标注(com接口)

    主要用到函数说明: _DMxDrawX::DrawDimRotated 绘制一个线型标注.详细说明如下: 参数 说明 DOUBLE dExtLine1PointX 输入第一条界线的起始点X值 DOUB ...

  6. windows开发错误

    2018/07/16: 1.问题: 代码: list <int> listN; error C2065:'list' : undeclared identifier 我已经#include ...

  7. java_线程的通信

    线程的通信共有三个方法: wait()运行时阻塞,释放锁 notify()唤醒阻塞线程 notifll()唤醒全部阻塞线程 public class ThreadTest01 { public sta ...

  8. Python --- 二叉树的层序建立与三种遍历

    二叉树(Binary Tree)时数据结构中一个非常重要的结构,其具有....(此处省略好多字)....等的优良特点. 之前在刷LeetCode的时候把有关树的题目全部跳过了,(ORZ:我这种连数据结 ...

  9. android实战简易教程-链接

    http://blog.csdn.net/yayun0516/article/category/2799943

  10. CF508E Arthur and Brackets

    题目大意:给出n对括号,并给出每对括号距离的范围.问能否找到这样一个序列. 题解:好多人都用贪心.这么好的题为什么不搜一发呢? 注意:千万不要在dfs里面更新答案. 代码: #include<c ...