問題一覧 > 通常問題

No.965 I Hate Kadomatsu Sequences

レベル : / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 388
作問者 : nmnmnmnmnmnmnm / テスター : uwi
お気に入りにしたユーザー ProblemId : 3659 / 自分の提出
問題文最終更新日: 2020-01-13 19:35:45
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 233 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。