[CF] 950A Left-handers, Right-handers and Ambidexters
A. Left-handers, Right-handers and Ambidexters
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
You 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.
Input
The 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.
Output
Print 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.
Examples
inputCopy
1 4 2
output
6
inputCopy
5 5 5
output
14
inputCopy
0 2 0
output
0
Note
In 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<iostream>
using namespace std;
int n,l,r,b;
int main(){
cin>>l>>r>>b;
while(b--){
if(l<r) l++;
else r++;
}
cout<<min(l,r)*2;
return 0;
}
[CF] 950A Left-handers, Right-handers and Ambidexters的更多相关文章
- 将多个Sheet导入到同一个Excel文件中
实体类excel import java.util.List; /** * 功能: * 描述: * @author * @date 2015-3-19 下午5:15:48 */ public clas ...
- Ansible入门知识
一.ansible概述 Ansible是一款为类Unix系统开发的自由开源的配置和自动化工具.它用Python写成,类似于saltstack和Puppet,但是有一个不同和优点是我们不需要在节点中安装 ...
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- cf Round 613
A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...
- ARC下OC对象和CF对象之间的桥接(bridge)
在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...
- [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现
1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...
- CF memsql Start[c]UP 2.0 A
CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...
- CF memsql Start[c]UP 2.0 B
CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...
随机推荐
- 洛谷 - P1111 - 修复公路 - 并查集
https://www.luogu.org/problemnew/solution/P1111 并查集的水题,水题都错了好多发. 首先并不是有环就退出,而是连通分支为1才退出,每次合并成功连通分支才会 ...
- Codeforces731E Funny Game
dp[i][0]表示从i出发,轮到先手走的最优值. dp[i][1]表示从i出发,轮到后手走的最优值. dp[i][0]=max(dp[j][1]+sum[j]) dp[i][1]=min(dp[j] ...
- Ubuntu解决中文乱码
gsettings set org.gnome.gedit.preferences.encodings candidate-encodings "['GB18030', 'UTF-8', ' ...
- the little schemer 笔记(9)
第九章 ...and Again, and Again, and, Again, ... 你想来点鱼子酱吗? 那就去找它吧. (looking a lat)是什么,其中a是 caviar, lat是( ...
- linux虚拟机时间不准的问题
如果时区不准, 使用tzselect命令(timezone选择),选择北京时间.然后把输出的命令写入/etc/profile.d/time.sh里. 然后用crontab写定时任务,每天执行一次. 3 ...
- 模拟+位运算 HDOJ 5491 The Next
题目传送门 题意:意思很简单,找一个最接近D且比D大的数,满足它的二进制表示下的1的个数在[S1, S2]之间 分析:从D + 1开始,若个数小于S1,那么从低位向高位把0替换成1直到S1就是最小值, ...
- DFS水题 URAL 1152 False Mirrors
题目传送门 /* 题意:一个圈,每个点有怪兽,每一次射击能消灭它左右和自己,剩余的每只怪兽攻击 搜索水题:sum记录剩余的攻击总和,tot记录承受的伤害,当伤害超过ans时,结束,算是剪枝吧 回溯写挫 ...
- 525 Contiguous Array 连续数组
给定一个二进制数组, 找到含有相同数量的 0 和 1 的最长连续子数组.示例 1:输入: [0,1]输出: 2说明: [0, 1] 是具有相同数量0和1的最长连续子数组. 示例 2:输入: [0,1, ...
- AJPFX总结面向对象(this和super的区别和应用)
面向对象(this和super的区别和应用)(掌握)* A:this和super都代表什么 * this:代表当前对象的引用,谁来调用我,我就代表谁 * super:代表当 ...
- 【学习笔记】Sass入门指南
本文将介绍Sass的一些基本概念,比如说“变量”.“混合参数”.“嵌套”和“选择器继承”等.著作权归作者所有. 什么是Sass? Sass是一门非常优秀的CSS预处语言,他是由Hampton Catl ...