A11061 | Tea Party
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
- 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.
输入格式
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$ ).
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted