Poisonous Cookies

AtCoder
IDagc030_a
Time2000ms
Memory256MB
Difficulty
Takahashi has $A$ untasty cookies containing antidotes, $B$ tasty cookies containing antidotes and $C$ tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat. ## Constraints * $0 \leq A,B,C \leq 10^9$ * $A,B$ and $C$ are integers. ## Input Input is given from Standard Input in the following format: $A$ $B$ $C$ [samples]
Samples
Input #1
3 1 4
Output #1
5

We can eat all tasty cookies, in the following order:

*   A tasty cookie containing poison
*   An untasty cookie containing antidotes
*   A tasty cookie containing poison
*   A tasty cookie containing antidotes
*   A tasty cookie containing poison
*   An untasty cookie containing antidotes
*   A tasty cookie containing poison
Input #2
5 2 9
Output #2
10
Input #3
8 8 1
Output #3
9
API Response (JSON)
{
  "problem": {
    "name": "Poisonous Cookies",
    "description": {
      "content": "Takahashi has $A$ untasty cookies containing antidotes, $B$ tasty cookies containing antidotes and $C$ tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc030_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Takahashi has $A$ untasty cookies containing antidotes, $B$ tasty cookies containing antidotes and $C$ tasty cookies containing poison.\nEating a cookie containing poison results in a stomachache, and ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments