题目链接:https://vjudge.net/contest/226823#problem/B

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 ypoints (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, nis 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.

Examples

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个数,已知其中k个,且所有数的大小都不超过p且不小于1。问是否有这样一组数,满足:他们的和不超过x,中位数不小于y?

代码如下:

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long LL;
const double eps = 1e-;
const int INF = 2e9;
const LL LNF = 9e18;
const int MOD = 1e9+;
const int MAXN = 1e5+; int n, k, p, x, y, a[MAXN];
int main()
{
while(cin>>n>>k>>p>>x>>y)
{
int left = x;
for(int i = ; i<=k; i++)
scanf("%d",&a[i]), left -= a[i]; sort(a+,a++k); //对已有的数进行排序
int mid = (n+)/; //中位数的下标
int pos = lower_bound(a+,a++k,y)-(a+); //求出比y小的最大的数的下标(亦是个数)
if(pos>=mid) //如果下标达到或超过了中位数的下标,则必定满足不了条件
left = -;
else //没有达到中位数的下标,则继续
{
int cnt = mid--pos; //为了尽可能保留left,在中位数之前的剩余空位全部放1
for(int i = k+; i<=k+cnt&&i<=n; i++)
a[i] = , left -= ;
for(int i = k+cnt+; i<=n; i++) //中位数以及剩余的为全部放y。
a[i] = y, left -= y;
} if(left<)
puts("-1");
else
{
for(int i = k+; i<=n; i++)
printf("%d ", a[i]);
puts("");
}
}
}

最新文章

  1. 遍历List集合,删除符合条件的元素
  2. 数据库操作(C#)
  3. salt安装zabbix
  4. Web Component 文章
  5. 弱安全协议探测工具-sslciphercheck
  6. studio中集成.so文件的两种方式
  7. SPRING 配置文件和类名
  8. linux服务器被攻击处理过程
  9. C# Redis学习系列三:Redis配置主从
  10. BFS学习 Codeforces 301_div.2_Ice Cave
  11. Activiti初学问题,求解
  12. power shell 脚本了解
  13. Linux~Archer 进化之路
  14. SDL播放YUV----单帧
  15. CCS中cmd文件的编写
  16. flask中单选、多选、下拉框的获取
  17. WPF的5种绑定模式(mode)
  18. 爬虫--Scrapy-持久化存储操作
  19. Python: 调用youtube_dl实现视频下载
  20. ios 内存管理与property copy strong weak assign

热门文章

  1. 2016.7.5 如何在maven中添加所需依赖(只知道jar包的部分名字的情况)
  2. 【C语言天天练(十一)】深入理解指针
  3. hdu 4372 第一类斯特林数
  4. jquery代码小片段
  5. (二)关于jQuery
  6. github 迁移google code 项目
  7. vim &#160;模式查找
  8. IP地址 网段的划分
  9. HDU BestCoder Round #1 1002 项目管理
  10. gulp 静态资源版本控制