CF540B.School Marks

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 _a_1, ..., a__k. 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.

小沃瓦在一所精英学校学习编程。沃瓦和他的同学们需要完成 nn 次阶段性测验,每次测验的得分范围为 11 到 pp。沃瓦非常聪明,他有能力在任意一次测验中取得任意分数,但他并不想过于突出而引起他人注意。如果他所有测验得分的总和超过数值 xx,那么他的同学们就会察觉到他有多聪明,并开始打扰他,要求抄他的作业;而如果他所有测验得分的中位数低于 yy 分(中位数的定义见注释),那么他的妈妈就会认为他得了太多低分,从而禁止他玩电脑游戏。

沃瓦已经完成了 kk 次测验,得分分别为 a1, …, aka_1,\, \dots,\, a_k。他希望避免上述两种情况的发生,现在他需要确定剩余测验应获得哪些分数。请帮助他完成这一任务。

输入格式

The first line contains 5 space-separated integers: n, k, p, x 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: _a_1, ..., a__k (1 ≤ a__i ≤ p) — the marks that Vova got for the tests he has already written.

第一行包含 5 个用空格分隔的整数:nn、kk、pp、xx 和 yy(其中 1 ≤ n ≤ 9991 ≤ n ≤ 999,nn 为奇数,0 ≤ k < n0 ≤ k < n,1 ≤ p ≤ 10001 ≤ p ≤ 1000,n ≤ x ≤ n ⋅ pn ≤ x ≤ n · p,1 ≤ y ≤ p1 ≤ y ≤ p)。其中,nn 表示 Vova 计划参加的考试总场数,kk 表示他已参加的考试场数,pp 表示单场考试的最高得分,xx 表示使得同学们尚未打扰 Vova 的最高总分,yy 表示使得妈妈仍允许他玩电脑游戏的最低中位数得分。

第二行包含 kk 个用空格分隔的整数:a1, ..., aka_1,\ ..., \ a_k(其中 1 ≤ ai ≤ p1 ≤ a_i ≤ p),表示 Vova 已参加的各场考试所获得的分数。

输出格式

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.

如果沃瓦无法达到期望的结果,则输出 -1。

否则,输出 n - k 个用空格分隔的整数——即沃瓦在剩余测试中应获得的成绩。若存在多种可能的解,输出任意一种即可。

输入输出样例

  • 输入#1

    5 3 5 18 4
    3 5 4

    输出#1

    4 1
  • 输入#2

    5 3 5 16 4
    5 5 5

    输出#2

    -1

说明/提示

The median of sequence _a_1, ..., a__n 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 a__i.

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".

序列 a1,…,ana_1, \dots, a_n 的中位数(本题中 nn 恒为奇数)定义为将所有 aia_i 升序排列后,位于第 (n+1)/2(n+1)/2 个位置上的元素。

在第一个样例中,分数总和为 3+5+4+4+1=173 + 5 + 4 + 4 + 1 = 17,未超过 1818,说明 Vova 不会被同学打扰;而序列 {1,3,4,4,5}\{1, 3, 4, 4, 5\} 的中位数为 44,不小于 44,因此他妈妈允许他玩电脑游戏。

请注意:你无需使分数总和或中位数最大化。对于第一个测试用例,以下任意一种答案均正确:“4 2”、“2 4”、“5 1”、“1 5”、“4 1”、“1 4”。

在第二个样例中,Vova 已获得三个“5”分,因此即使他再得两个“1”分,总分也将达到 1717,超过所要求的上限 1616。故该测试用例的答案为 -1。

输入解题思路,AI测评打分。不知道怎么写?

首页