Difference Max

AtCoder
IDabc196_a
Time2000ms
Memory256MB
Difficulty
Given are integers $a$, $b$, $c$, and $d$. We will choose integers $x$ and $y$ such that $a ≤ x ≤ b$ and $c ≤ y ≤ d$. Find the maximum possible value of $x - y$ here. ## Constraints * All values in input are integers. * $-100 ≤ a ≤ b ≤ 100$ * $-100 ≤ c ≤ d ≤ 100$ ## Input Input is given from Standard Input in the following format: $a$ $b$ $c$ $d$ [samples]
Samples
Input #1
0 10
0 10
Output #1
10

$(x, y) = (10, 0)$ achieves the maximum value $x - y = 10$.
Input #2
\-100 -100
100 100
Output #2
\-200
Input #3
\-100 100
-100 100
Output #3
200
API Response (JSON)
{
  "problem": {
    "name": "Difference Max",
    "description": {
      "content": "Given are integers $a$, $b$, $c$, and $d$.   We will choose integers $x$ and $y$ such that $a ≤ x ≤ b$ and $c ≤ y ≤ d$. Find the maximum possible value of $x - y$ here.",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc196_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given are integers $a$, $b$, $c$, and $d$.  \nWe will choose integers $x$ and $y$ such that $a ≤ x ≤ b$ and $c ≤ y ≤ d$. Find the maximum possible value of $x - y$ here.\n\n## Constraints\n\n*   All values...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments