AtCoder Regular Contest 143
翻译中…
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.
翻译中…
样例
Input #1
2 2 3
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$.
Input #2
0 0 1
Output #2
-1
Input #3
0 0 0
Output #3
0
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。