301130: CF209B. Pixels

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Pixels

题意翻译

**完整题面** 一个地方居住着三种颜色的元素:红色、绿色和蓝色。如果两个不同颜色的元素在一场激烈的战斗中相遇,那么其中只有一个幸存下来(也就是说,元素总数减少了一个)。此外,如果颜色 $x$ 和 $y$ 的元素在战斗中相遇,那么在战斗中幸存下来的元素立即将其颜色更改为 $z$($z\not =x,z\not = y$ ) 。相同颜色的元素不会打架。 国王知道,当所有元素颜色相同时,他的领土将和平繁荣。对于这三种元素中的每一种,您都知道居住在这里的这种元素的数量。帮助国王确定战斗是否能给国家带来和平与繁荣,如果可能的话,找到使国家和平与繁荣所需的最少战斗次数。 **题意简述** 有 $3$ 个数 $a,b,c$,每次操作可以使两个数 $-1$ ,另一个数 $+1$,求让其中两个数为 $0$ 的最少操作次数。 translate by @[hanyuchen2019](https://www.luogu.com.cn/user/277757)

题目描述

Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels of colors $ x $ and $ y $ $ (x≠y) $ meet in a violent fight, then the pixel that survives the fight immediately changes its color to $ z $ $ (z≠x; z≠y) $ . Pixels of the same color are friends, so they don't fight. The King of Flatland knows that his land will be peaceful and prosperous when the pixels are of the same color. For each of the three colors you know the number of pixels of this color that inhabit Flatland. Help the king and determine whether fights can bring peace and prosperity to the country and if it is possible, find the minimum number of fights needed to make the land peaceful and prosperous.

输入输出格式

输入格式


The first line contains three space-separated integers $ a $ , $ b $ and $ c $ $ (0<=a,b,c<=2^{31}; a+b+c&gt;0) $ — the number of red, green and blue pixels, correspondingly.

输出格式


Print a single number — the minimum number of pixel fights before the country becomes peaceful and prosperous. If making the country peaceful and prosperous is impossible, print -1.

输入输出样例

输入样例 #1

1 1 1

输出样例 #1

1

输入样例 #2

3 1 0

输出样例 #2

3

说明

In the first test sample the country needs only one fight to achieve peace and prosperity. Besides, it can be any fight whatsoever. For example, let's assume that the green and the blue pixels fight, then the surviving pixel will be red. As a result, after the fight there are two red pixels. There won't be other pixels. In the second sample the following sequence of fights is possible: red and blue, green and red, red and blue. As a result, after all fights there is one green pixel left.

Input

题意翻译

**完整题面** 一个地方居住着三种颜色的元素:红色、绿色和蓝色。如果两个不同颜色的元素在一场激烈的战斗中相遇,那么其中只有一个幸存下来(也就是说,元素总数减少了一个)。此外,如果颜色 $x$ 和 $y$ 的元素在战斗中相遇,那么在战斗中幸存下来的元素立即将其颜色更改为 $z$($z\not =x,z\not = y$ ) 。相同颜色的元素不会打架。 国王知道,当所有元素颜色相同时,他的领土将和平繁荣。对于这三种元素中的每一种,您都知道居住在这里的这种元素的数量。帮助国王确定战斗是否能给国家带来和平与繁荣,如果可能的话,找到使国家和平与繁荣所需的最少战斗次数。 **题意简述** 有 $3$ 个数 $a,b,c$,每次操作可以使两个数 $-1$ ,另一个数 $+1$,求让其中两个数为 $0$ 的最少操作次数。 translate by @[hanyuchen2019](https://www.luogu.com.cn/user/277757)

加入题单

算法标签: