304236: CF808C. Tea Party

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Tea Party

题意翻译

有n个客人到小名家来玩,他们每人酒杯的容量为a[i],小名家里共有w(w<=a[1]+a[2]+....)容量的酒,他们现在要喝酒,如果满足以下四个条件,证明这个倒酒方法是合法的。 1.每个人倒得酒必须不小于容量的一半 2.每个人倒得酒都是整数 3.所有的酒都倒满了。 4.每个朋友都是快乐的。 如果第a[i]>a[j]但是i装的酒小于j的,那么i是不快乐的。 输入格式: 第一行2个整数n,w 接下来一行n个整数,a[i] 输出格式: 输出一种合法的倒酒方法,如果有多解,输出任意1解,如果没有一种合法的,输出-1 样例3解释:没人至少倒得酒之和:5+4+5=14,大于w的10 感谢@Hjl1777 提供的翻译

题目描述

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}&gt;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.

输入输出格式

输入格式


The first line contains two integer numbers $ n $ and $ w $ ( $ 1<=n<=100 $ , ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF808C/5b15eb8aa6cebecb1cf5b08f4e387ed47abfcf91.png)). The second line contains $ n $ numbers $ a_{1},a_{2},...,a_{n} $ ( $ 1<=a_{i}<=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

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.

Input

题意翻译

有n个客人到小名家来玩,他们每人酒杯的容量为a[i],小名家里共有w(w<=a[1]+a[2]+....)容量的酒,他们现在要喝酒,如果满足以下四个条件,证明这个倒酒方法是合法的。 1.每个人倒得酒必须不小于容量的一半 2.每个人倒得酒都是整数 3.所有的酒都倒满了。 4.每个朋友都是快乐的。 如果第a[i]>a[j]但是i装的酒小于j的,那么i是不快乐的。 输入格式: 第一行2个整数n,w 接下来一行n个整数,a[i] 输出格式: 输出一种合法的倒酒方法,如果有多解,输出任意1解,如果没有一种合法的,输出-1 样例3解释:没人至少倒得酒之和:5+4+5=14,大于w的10 感谢@Hjl1777 提供的翻译

加入题单

算法标签: