201430: [AtCoder]ARC143 A - Three Integers

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

Description

Score : $300$ points

Problem Statement

Three non-negative integers $A$, $B$, and $C$ are written on a blackboard. You can perform the following two operations any number of times in any order.

  • Subtract $1$ from two of the written integers of your choice.
  • Subtract $1$ from all of the written integers.

Your objective is to make all the numbers on the blackboard $0$. Determine whether it is achievable. If it is, find the minimum number of times you need to perform an operation to achieve it.

Constraints

  • $0 \leq A, B, C \leq 10^{18}$

Input

Input is given from Standard Input in the following format:

$A$ $B$ $C$

Output

If the objective is unachievable, print -1. If it is achievable, print the minimum number of times you need to perform an operation to achieve it.


Sample Input 1

2 2 3

Sample Output 1

3

Here is one way to make all the numbers $0$.

  • Subtract $1$ from $A$ and $C$. Now the numbers are $1$, $2$, $2$.
  • Subtract $1$ from $B$ and $C$. Now the numbers are $1$, $1$, $1$.
  • Subtract $1$ from all the numbers. Now the numbers are $0$, $0$, $0$.

Sample Input 2

0 0 1

Sample Output 2

-1

Sample Input 3

0 0 0

Sample Output 3

0

Input

题意翻译

黑板上写着三个整数 $A,B,C$。 你可以以任意顺序执行一下两个操作任意次: - 选择其中两个数,并将这两个数减 $1$。 - 将三个数都减 $1$。 你的目标是使黑板上的所有数字都为 $0$。 确定目标是否可以实现。如果是,请输出最少的操作次数。

加入题单

算法标签: