問題一覧 > 通常問題

No.1860 Magnets

レベル : / AI推定難易度 : 275 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 189
作問者 : MtSaka / テスター : ぷら shiomusubi496
お気に入りにしたユーザー ProblemId : 7345 / 自分の提出
問題文最終更新日: 2022-03-04 19:49:07
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 334 (順位表) の他の問題:

Problem Statement

In the Shinpuro Kingdom, there are $2$ types of magnets: magnet $X$, whose $N$-pole side is red and whose $S$-pole side is blue, and magnet $Y$, whose $S$-pole side is red and whose $N$-pole side is blue.

Consider arranging all of the $A$ magnets $X$ and $B$ magnets $Y$ in a row. Here, adjacent magnets must be joined with opposite poles touching each other.

When looking at the colors of the magnets arranged in a row, what is the minimum number of places where the color changes?

Note that all of these magnets consist of the $2$ colors red and blue, and each has exactly one color boundary, in its middle.

(Original idea: Cyanmond)

Input

$A$ $B$
  • $0 \leq A,B \leq 10^9$
  • $A, B$ are integers

Output

Print the answer to the problem as a number on one line.

Sample

Sample 1
Input
3 4
Output
7

For example, they can be placed as follows.



In this case, there are $7$ color boundaries. It is impossible to have $6$ or fewer color boundaries, so print $7$.

Sample 2
Input
33 4
Output
65

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。