Tea Party

学习提速专享!AI工具全家桶免费用 限时购周边加赠Coding Plan Lite,解锁20+主流AI工具,写代码、查资料快人一步! 阅读详情

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 a1, a2, ..., an. His teapot stores w milliliters of tea (w ≤ a1 + a2 + ... + an). 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 ai > aj.

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.


Input

The first line contains two integer numbers n and w (1 ≤ n ≤ 100, ).

The second line contains n numbers a1, a2, ..., an (1 ≤ ai ≤ 100).

Output

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.

Examples
Input
2 10
8 7
Output
6 4 
Input
4 4
1 1 1 1
Output
1 1 1 1 
Input
3 10
9 8 10
Output
-1
Note

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.


#include<bits/stdc++.h>
using namespace std;

typedef pair<int,int> p;

int main(){
    int n,w;
    cin>>n>>w;
    vector<p> v(n);
    vector<int> r(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first;
        v[i].second=i;
        r[i]=(v[i].first+1)/2;
        w-=r[i];
    }
    if(w<0){
        puts("-1");return 0;
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<n;i++){
        int mm=min(v[i].first-r[v[i].second],w);
        r[v[i].second]+=mm;
        w-=mm;
    }
    for(int i=0;i<n;i++)
    if(i==0)cout<<r[i];
    else cout<<" "<<r[i];

}

一次有趣的茶话会 6月24日下午,我替我们部门的高老师,去参加了一个“档案联络员”会议,这是工作以来,第1次参加学院的会议,会议另我别开生面,会议居然可以吃东西,呵呵。桌上堆满了荔枝、瓜子、花生、糖等等。     我们边吃边听,一场会议下来,我就仅仅记下了2个问题。    (1)什么是档案?    (2)什么是资料?    作为档案联络员,应该做些什么?怎么样确定自己部门的档案?     第1次开会,也没啥准备,所 阅读详情

相关推荐

茶话会java_VGA茶话会

yuzu emulatoryuzu is an experimental open-source emulator for the Nintendo Switch from the creators of Citra.It is written in C++ with portability in mind, with builds actively maintained for Windows ...

weixin_42350554的博客 177

贪心之------Tea Party

这道题大致意思就是N个杯子的容积和茶壶的容积,要满足三个条件(1.每一个杯子里面的茶必须严格大于它容积的一半 2.茶壶往所有杯子到满水后没有生于地茶 3.所有的客人必须满意) 使客人满意的话,就是一个杯子里面的茶水必须大于任意一个容积小于它的杯子里面的茶水 Tea Party Polycarp invited all his friends to the tea party to celebrat...

qq_33961229的博客 446

codeforces 808C——Tea Party(贪心)

C. Tea Party time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp invited all his friends to the tea par

say_c_box的博客 1386

poj 1455 Crazy tea party

Crazy tea party Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6220 Accepted: 4180 Description n participants of << crazy tea party >> sit around the table. Each minute one...

weixin_30455661的博客 83

Crazy tea party

n participants of &lt;&lt; crazy tea party &gt;&gt; sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minutes) required for all participants to...

十早韦的博客 281

Crazy Tea Party

n participants of "crazy tea party" sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minutes) required for all participants to sit in reverse

当凌绝顶,俯瞰天下 1524

POJ 1455 Crazy tea party

POJ 1455 Crazy tea party,环形座位逆序

恰同学少年 3564

ZOJ 1730 Crazy Tea Party

Crazy Tea Party Time Limit: 2 Seconds      Memory Limit: 65536 KB n participants of "crazy tea party" sit around the table. Each minute one pair of neighbors can change their places. Find the mi

胖子加油! 344

C. Tea Party

// Problem: C. Tea Party // Contest: Codeforces - Educational Codeforces Round 21 // URL: https://codeforces.com/problemset/problem/808/C // Memory Limit: 256 MB // Time Limit: 1000 ms // 2022-03-12 13:51:38 // // Powered by CP Editor (https://cpeditor.or

qq_28409093的博客 312

FZOJ 1157 Crazy Tea Party

OJ题目:click here~~ 题目分析:1……n按顺序围成一个圈,1与n相邻。交换相邻两个数算1步。至少需要多少步,得到一个逆方向的1……n的圈。 分两半,使用冒泡排序,排成逆序的交换次数之和即为结果。 AC_CODE int f(int n){ return n*(n - 1)/2; } int main(){ int n , t; cin >> t;

834

codeforces 808 C. Tea Party

C. Tea Party time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp invited all his friends to the tea party to celebrate the ho...

qq_36996464的博客 332

zoj 1730 Crazy Tea Party

//水题不水啊! /*类似冒泡程序 如果所有人是线性排列,那我们的工作就是类似冒泡程序做的工作:1,2,3,4,5变为5,4,3,2,1 ,耗时n(n-1)/2 但是出现了环,也就是说1,2,3,4,5变为3,2,1,5,4也可满足条件 我们可以把这个环等分成两个部分 ,每个部分看成是线性的,再把它们花的时间加起来. 当n是偶数时, 每份人数n/2 ,即 2*(n/2 )*(n/2 -1

yzl_rex 1543

Debauchery Tea PartyC++笔记④

迭代器 所有标准库容器都可以使用迭代器,string也支持迭代器。类似于指针类型,迭代器也提供了对对象的间接访问,其对象是容器中的元素和string中的字符。使用迭代器可以访问某个元素,也能从一个元素移动到另一个元素。 迭代器有有效和无效之分,有效的迭代器指向某个元素或者指向容器末尾元素的下一位置。其他情况都属于无效。 使用迭代器 有迭代器的类型同时拥有返回迭代器的成员。一个成员 ...

qq_54879044的博客 369

fjnu 1655 Crazy tea party

Descriptionn participants of ?crazy tea party? sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minutes) required for all participants to

异リ度ュ空ウ間(镜像站) 870
上一篇: aizu_Largest Rectangle
下一篇: Average Sleep Time_CodeForces - 808B
ujn20161222
博客等级 码龄9年 970粉丝 1447原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值