Codeforces Round #469 (Div. 2) A. Left-handers, Right-handers and Ambidexters(水)
2018-03-11 15:06
525 查看
题目链接:点击打开链接
A. Left-handers, Right-handers and Ambidexters
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard 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 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 zer
4000o number of players.
Examples
input
Copy
output
input
Copy
output
input
Copy
output
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就行了。
具体实现看代码:
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int l,r,a;
cin >> l >> r >> a;
while(a){
int maxx = max(l,r);
int minn = min(l,r);
minn++;
a--;
l = maxx;
r = minn;
}
cout << min(l,r) * 2 <<endl;
}
A. Left-handers, Right-handers and Ambidexters
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard 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 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 zer
4000o 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.
题意:你有三种人,分别为擅长使用左手的人,擅长使用右手的人,和不仅擅长使用左手还擅长是由右手的人(天选之人?)。然后你要从这个三种人组建一直队伍。队伍的要求为:使用左手和使用右手的人一样多。求队伍的最大人数。
题解:把天选之人。分配给使用单手人数少的。然后单手数量少的乘2就行了。
具体实现看代码:
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int l,r,a;
cin >> l >> r >> a;
while(a){
int maxx = max(l,r);
int minn = min(l,r);
minn++;
a--;
l = maxx;
r = minn;
}
cout << min(l,r) * 2 <<endl;
}
相关文章推荐
- Codeforces Round #469 (Div. 2) A. Left-handers, Right-handers and Ambidexters
- Codeforces Round #469 (Div. 2) A - Left-handers, Right-handers and Ambidexters
- Codeforces Round #442 (Div. 2) E. Danil and a Part-time Job DFS序+树链剖分+线段树区间^
- Codeforces Round #269 (Div. 2) A. MUH and Sticks
- Codeforces Round #379 (Div. 2) D. Anton and Chess 模拟
- Codeforces Round #305 (Div. 2), problem: (A) Mike and Fax
- Codeforces Round #263 (Div. 1) B. Appleman and Tree(给一棵树,每个点为白色或黑色,切断一些边,使得每个连通块有且仅有一个黑点,问划分方案数。)
- Codeforces Round #253 (Div. 2)A. Anton and Letters
- Codeforces Round #253 (Div. 1) A. Borya and Hanabi 暴力
- Codeforces Round #372 (Div. 2) C. Plus and Square Root —— 构造(数学题)
- Educational Codeforces Round 37 (Rated for Div. 2) F. SUM and REPLACE(线段树)
- Codeforces Round #204 (Div. 1) E. Jeff and Permutation
- Codeforces Round #285 (Div. 2) C. Misha and Forest
- Codeforces Round #421 (Div. 1):B. Mister B and PR Shifts(瞎搞)
- 【Codeforces Round 332 (Div 2)D】【数学 公式推导】Spongebob and Squares 正方形数量恰好为x个的所有大矩形
- 【Codeforces Round 330 (Div 2)A】【水题】Vitaly and Night 多少间房间有人
- 【Codeforces Round 331 (Div 2)B】【水题 贪心】Wilbur and Array 修改对p位置后的所有位置生效 最少修改次数使得数列变成b
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution(STL乱搞)
- Codeforces Round #264 (div2)B. Caisa and Pylons
- Codeforces Round #358 (Div. 2) B. Alyona and Mex