CF808C.Tea Party
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Polycarp invited all his friends to the tea party to celebrate the holiday. He has n cups, one for each of his n friends, with volumes _a_1, _a_2, ..., a__n. His teapot stores w milliliters of tea (w ≤ _a_1 + _a_2 + ... + a__n). Polycarp wants to pour tea in cups in such a way that:
- Every cup will contain tea for at least half of its volume
- Every cup will contain integer number of milliliters of tea
- All the tea from the teapot will be poured into cups
- All friends will be satisfied.
Friend with cup i won't be satisfied, if there exists such cup j that cup i contains less tea than cup j but a__i > a__j.
For each cup output how many milliliters of tea should be poured in it. If it's impossible to pour all the tea and satisfy all conditions then output -1.
波利卡普邀请了他所有的朋友来参加茶会,以庆祝节日。他有 n 个杯子,每个朋友一个,容量分别为 a1,a2,…,an。他的茶壶中装有 w 毫升茶水(满足 w≤a1+a2+⋯+an)。波利卡普希望将茶水倒入杯子中,使得满足以下条件:
- 每个杯子中的茶水量至少为其容量的一半;
- 每个杯子中的茶水量为整数毫升;
- 茶壶中的所有茶水必须全部倒入杯子中;
- 所有朋友都感到满意。
对于第 i 个杯子的朋友来说,若存在某个杯子 j,使得第 i 个杯子中的茶水量 少于 第 j 个杯子中的茶水量,但第 i 个杯子的容量 ai 大于 第 j 个杯子的容量 aj,则该朋友将 不满意。
对每个杯子,输出应倒入的茶水量(单位:毫升)。如果无法在满足所有条件的前提下倒完全部茶水,则输出 −1。
输入格式
The first line contains two integer numbers n and w (1 ≤ n ≤ 100,
).
The second line contains n numbers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 100).
第一行包含两个整数 $ n $ 和 $ w ( 1 \leq n \leq 100 $,
)。
第二行包含 $ n $ 个数 $ a_1,,a_2,,...,,a_n ( 1 \leq a_i \leq 100 $)。
输出格式
Output how many milliliters of tea every cup should contain. If there are multiple answers, print any of them.
If it's impossible to pour all the tea and satisfy all conditions then output -1.
输出每个杯子应盛放多少毫升的茶。如果有多个答案,输出任意一个即可。
如果无法将所有茶水倒完并同时满足所有条件,则输出 −1。
输入输出样例
输入#1
2 10 8 7
输出#1
6 4
输入#2
4 4 1 1 1 1
输出#2
1 1 1 1
输入#3
3 10 9 8 10
输出#3
-1
说明/提示
In the third example you should pour to the first cup at least 5 milliliters, to the second one at least 4, to the third one at least 5. It sums up to 14, which is greater than 10 milliliters available.
在第三个例子中,您至少需要向第一个杯子倒入 5 毫升,向第二个杯子倒入至少 4 毫升,向第三个杯子倒入至少 5 毫升。总和为 14 毫升,超过了可用的 10 毫升。
输入解题思路,AI测评打分。不知道怎么写?