博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[CF] 950A Left-handers, Right-handers and Ambidexters
阅读量:7213 次
发布时间:2019-06-29

本文共 1937 字,大约阅读时间需要 6 分钟。

A. Left-handers, Right-handers and Ambidexterstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are at a water bowling training. There are l people who play with their left hand, r people, who play with their right hand, and a ambidexters, who can play with left or right hand.The coach decided to form a team of even number of players, exactly half of the players should play with their right hand, and exactly half of the players should play with their left hand. One player should use only on of his hands.Ambidexters play as well with their right hand as with their left hand. In the team, an ambidexter can play with their left hand, or with their right hand.Please find the maximum possible size of the team, where equal number of players use their left and right hands, respectively.InputThe only line contains three integers l, r and a (0 ≤ l, r, a ≤ 100) — the number of left-handers, the number of right-handers and the number of ambidexters at the training.OutputPrint a single even integer — the maximum number of players in the team. It is possible that the team can only have zero number of players.ExamplesinputCopy1 4 2output6inputCopy5 5 5output14inputCopy0 2 0output0NoteIn the first example you can form a team of 6 players. You should take the only left-hander and two ambidexters to play with left hand, and three right-handers to play with right hand. The only person left can't be taken into the team.In the second example you can form a team of 14 people. You have to take all five left-handers, all five right-handers, two ambidexters to play with left hand and two ambidexters to play with right hand.

感觉就像在两个栈里加元素,贪心地想,每次加小的,最后小的元素个数*2就是相等的元素个数

//Stay foolish,stay hungry,stay young,stay simple#include
using namespace std;int n,l,r,b;int main(){ cin>>l>>r>>b; while(b--){ if(l

转载于:https://www.cnblogs.com/ghostcai/p/9247459.html

你可能感兴趣的文章
方案优化:网站实现扫描二维码关注微信公众号,自动登陆网站并获取其信息...
查看>>
Leetcode | Balanced Binary Tree
查看>>
sqlServer对内存的管理
查看>>
挑战密室
查看>>
利用Solr服务建立的站内搜索雏形---solr1
查看>>
5、jmeter-逻辑控制器介绍与使用
查看>>
如何遍历List对象
查看>>
2012年4月19日
查看>>
获取站点所有缓存,以及清除站点缓存
查看>>
oracle 是user_tables里面可以查找到一个表,而用DESC或者insert语句插入时就会报不存在视图。...
查看>>
找水王续
查看>>
cocos2d-x之Node移除HelloWorld节点
查看>>
AtCoder WTF 2019 C2. Triangular Lamps Hard
查看>>
[转].NET Framework、C#、CLR和Visual Studo之间的版本关系
查看>>
sql语句-2-字符串数字日期时间
查看>>
[Python3网络爬虫开发实战] 3.1.2-处理异常
查看>>
25、没有编程基础可以学习PHP吗?
查看>>
mybatis案例源码详解
查看>>
Python--day37--进程锁
查看>>
导出PDF乱码
查看>>