http://codeforces.com/problemset/problem/950/A
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 aambidexters, 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
input
Copy
1 4 2
output
6
input
Copy
5 5 5
output
14
input
Copy
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.
Google翻译:
你正在进行水上保龄球训练。有一些人用左手玩,右手用右手玩,还有一个可以用左手或右手玩的双手。
教练决定组成一支偶数球员的队伍,一半的球员应该用右手踢球,而一半的球员应该用左手球。一名球员只能用在他手上。
Ambidexters也可以用右手和左手玩。在队中,一名双手可以用左手或右手踢球。
请找出球队的最大可能规模,其中相同数量的球员分别使用他们的左手和右手。
输入
唯一的一行包含三个整数l,r和a(0≤l,r,a≤100) - 训练中左撇子的数量,右撇子的数量和双手臂的数量。
输出
打印一个单一的偶数 - 队中球员的最大数量。球队可能只有零个球员。
把a补给l或r,使min(l,r)最大。
#include<bits/stdc++.h>
using namespace std;
int main()
{
int l,r,m,ans=0;
cin>>l>>r>>m;
if(l>r)
swap(l,r); //保证r>l
int u=min(m,r-l); //较小的数要加的值
l+=u;
m-=u;
l+=m/2; //加上m剩余的一半
r+=m/2;
cout<<min(l,r)*2; //有两个对,所以*2
return 0;
}