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的更多相关文章

  1. 将多个Sheet导入到同一个Excel文件中

    实体类excel import java.util.List; /** * 功能: * 描述: * @author * @date 2015-3-19 下午5:15:48 */ public clas ...

  2. Ansible入门知识

    一.ansible概述 Ansible是一款为类Unix系统开发的自由开源的配置和自动化工具.它用Python写成,类似于saltstack和Puppet,但是有一个不同和优点是我们不需要在节点中安装 ...

  3. 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 ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  6. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  7. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. C++笔试题库之编程、问答题 200~300道

    201下面的代码有什么问题?并请给出正确的写法. void DoSomeThing(char* p) { char str[16]; int n; assert(NULL != p); sscanf( ...

  2. POJ2369【循环节】

    题意: 给一个序列,他需要几步就能变成原来的序列. 思路: 那么就是找一下各个循环节(用dfs随便搞了-),求一下最小公倍数就好了. 贴一发挫code- //#include <bits/std ...

  3. python __builtins__ enumerate类 (21)

    21.'enumerate', 用于将一个可遍历的数据对象(如列表.元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中. class enumerate(object ...

  4. bzoj 5496: [2019省队联测]字符串问题【SAM+拓扑】

    有一个想法就是暴力建图,把每个A向有和他相连的B前缀的A,然后拓扑一下,这样的图是n^2的: 考虑优化建图,因为大部分数据结构都是处理后缀的,所以把串反过来,题目中要求的前缀B就变成了后缀B 建立SA ...

  5. javascript E5面向对象和 E6面向对象

    javascript es6之前的面向对象方法: 一般使用构造函数来实现 function Person (name, age) { this.name = name; this.age = age; ...

  6. JDK由浅到深的理解

    一.JDK的安装 二.JDK安装后目录下的文件夹的用处 bin:编译器(javac.exe); db:jdk从1.6之后内置Derby数据库,它是一个纯用Java实现的内存数据库,Apache的开源项 ...

  7. Java中JRE、JDK和JVM的区别

    一.三者的基本概念: JRE(Java Development Kit):Java的运行环境: JDK(Java Runtime Enviroment):Java开发工具包: JVM(Java Vir ...

  8. eclipse中alt+/的作用

    一般情况下alt+/有代码提示作用,还有代码提示的快捷代码也不是alt+/,因此要恢复代码提示用alt+/.需要做两件事.在 Window - Preferences - General - Keys ...

  9. Tensorflow多线程输入数据处理框架(一)——队列与多线程

    参考书 <TensorFlow:实战Google深度学习框架>(第2版) 对于队列,修改队列状态的操作主要有Enqueue.EnqueueMany和Dequeue.以下程序展示了如何使用这 ...

  10. PHP + jquery.validate remote的用法

    [ 转 ] http://www.cnlvzi.com/index.php/Index/article/id/58 最近做验证功能时,用到jquery.validate.js中的remote远程验证方 ...