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. Myeclipse 6.0代码

    import java.util.*; import java.io.*; public class bbs { private static final String LL = "Deco ...

  2. Android学习笔记(九) SeekBar和RatingBar

    一.SeekBar的主要属性 -max -progress -secondaryProgress 二.onSeekBarChangeListener -onProgressChanged(SeekBa ...

  3. iOS Programming Introduction to Auto Layout 自动布局

    iOS Programming Introduction to Auto Layout   自动布局 A single application that runs natively on both t ...

  4. Activity的四种启动模式区别

    (1) standard 模式启动模式,每次激活Activity时都会创建Activity,并放入任务栈中. (2) singleTop 如果在任务的栈顶正好存在该Activity的实例, 就重用该实 ...

  5. 从0开始搭建SQL Server 2012 AlwaysOn 第一篇(AD域与DNS)

    随着业务发展,公司需要提高数据安全与性能需求,所以需要对新技术预研(先采坑),做技术积累: 了解相关AlwaysOn 故障转移集群(热备),数据路由(ICX),Moebius(莫比斯数据路由) 决定测 ...

  6. flex布局(主要分清楚容器和条目)

    设置在容器上面的属性:flex-direction.flex-wrap.flex-flow.justify-content.align-items.align-content1.flex-direct ...

  7. Django 跨域CORS

    现在,前端与后端分处不同的域名,我们需要为后端添加跨域访问的支持. 我们使用CORS来解决后端对跨域访问的支持. 使用django-cors-headers扩展 参考文档https://github. ...

  8. 09CSS高级定位

    CSS高级定位 定位方式——position position:static|absolute|relative static表示为静态定位,是默认设置.  absolute表示绝对定位,与下位置属 ...

  9. No-8.循环

    01. 程序的三大流程 在程序开发中,一共有三种流程方式: 顺序 —— 从上向下,顺序执行代码 分支 —— 根据条件判断,决定执行代码的 分支 循环 —— 让 特定代码 重复 执行 02. while ...

  10. 零基础入门学习Python(8)--了不起的分支和循环2

    前言 上节课小甲鱼教大家如何正确的打飞机,其要点是判断和循环,判断就是该不该做某事,循环就是持续做某事 知识点 写一个程序 按照100分制,90分以上成绩为A,80到90为B,60到80为C,60以下 ...