Various distances

AtCoder
IDabc180_b
Time2000ms
Memory256MB
Difficulty
Given is a point $(x_1,\ldots,x_N)$ in an $N$\-dimensional space. Find the Manhattan distance, Euclidian distance, and Chebyshev distance between this point and the origin. Here, each of them is defined as follows: * The Manhattan distance: $|x_1|+\ldots+|x_N|$ * The Euclidian distance: $\sqrt{|x_1|^2+\ldots+|x_N|^2}$ * The Chebyshev distance: $\max(|x_1|,\ldots,|x_N|)$ ## Constraints * $1 \leq N \leq 10^5$ * $-10^5 \leq x_i \leq 10^5$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $N$ $x_1$ $\ldots$ $x_N$ [samples]
Samples
Input #1
2
2 -1
Output #1
3
2.236067977499790
2

Each of the distances is computed as follows:

*   The Manhattan distance: $|2|+|-1|=3$
*   The Euclidian distance: $\sqrt{|2|^2+|-1|^2}=2.236067977499789696\ldots$
*   The Chebyshev distance: $\max(|2|,|-1|)=2$
Input #2
10
3 -1 -4 1 -5 9 2 -6 5 -3
Output #2
39
14.387494569938159
9
API Response (JSON)
{
  "problem": {
    "name": "Various distances",
    "description": {
      "content": "Given is a point $(x_1,\\ldots,x_N)$ in an $N$\\-dimensional space. Find the Manhattan distance, Euclidian distance, and Chebyshev distance between this point and the origin. Here, each of them is defin",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc180_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given is a point $(x_1,\\ldots,x_N)$ in an $N$\\-dimensional space.\nFind the Manhattan distance, Euclidian distance, and Chebyshev distance between this point and the origin. Here, each of them is defin...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments