No.965 I Hate Kadomatsu Sequences
タグ : / 解いたユーザー数 388
作問者 :
nmnmnmnmnmnmnm
/ テスター :
Problem Statement
A Kadomatsu sequence is defined as follows: when 3 integers are arranged as $A$, $B$, $C$ from left to right,
all the values are distinct and the second largest integer among $A$, $B$, $C$ is either $A$ or $C$.
From what I've heard, it seems that many people hate Kadomatsu sequences.
You are given 3 positive integers $A$, $B$, $C$ in this order from left to right, forming a Kadomatsu sequence.
Perform the 3 operations below any number of times so that the conditions of a Kadomatsu sequence are no longer satisfied, at the minimum cost.
・At cost 1, subtract 1 from the integer $A$.
・At cost 1, subtract 1 from the integer $B$.
・At cost 1, subtract 1 from the integer $C$.
Input
$A$ $B$ $C$
$A$, $B$, $C$ are positive integers. $1 \le A,B,C \le 1000000000=10^9$.
The input $A$, $B$, $C$ always satisfies the conditions of a Kadomatsu sequence.
Output
Output the answer on one line.
Sample
Sample 1
Input
3 5 1
Output
2
There are several ways to make it not a Kadomatsu sequence.
Changing it to "3 2 1" at cost 3 makes it no longer a Kadomatsu sequence.
Changing it to "1 5 1" at cost 2 also makes it no longer a Kadomatsu sequence.
In this case, the minimum cost to make it not a Kadomatsu sequence is 2.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。