155. Array Statistics

Codeforces
IDCF10269155
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
For this task, you will be required to find a set of simple statistics based on a given set of data. Data will be provided as an array of integers, and you will be tasked with finding the mean, median, mode, and range of the data. The first line will contain $n$, the number of values in the array. The second line will contain space-separated integers that correspond to the array of input values. The output should print the mean, median, mode, and range of the provided data in order and separated by lines(ie. the first line has the mean, the second line has the median, etc). ## Input The first line will contain $n$, the number of values in the array. The second line will contain space-separated integers that correspond to the array of input values. ## Output The output should print the mean, median, mode, and range of the provided data in order and separated by lines(ie. the first line has the mean, the second line has the median, etc). [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $ denote the number of data points. Let $ A = (a_1, a_2, \dots, a_n) $ be a sequence of integers. **Constraints** $ n \geq 1 $, and $ a_i \in \mathbb{Z} $ for all $ i \in \{1, \dots, n\} $. **Objective** Compute the following statistics for $ A $: 1. **Mean**: $ \mu = \frac{1}{n} \sum_{i=1}^{n} a_i $ 2. **Median**: - If $ n $ is odd: $ \text{median} = a_{(n+1)/2} $ (after sorting) - If $ n $ is even: $ \text{median} = \frac{a_{n/2} + a_{n/2 + 1}}{2} $ (after sorting) 3. **Mode**: The value(s) with maximum frequency; if multiple, return the smallest such value. 4. **Range**: $ \text{range} = \max(A) - \min(A) $
API Response (JSON)
{
  "problem": {
    "name": "155. Array Statistics",
    "description": {
      "content": "For this task, you will be required to find a set of simple statistics based on a given set of data. Data will be provided as an array of integers, and you will be tasked with finding the mean, median",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269155"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "For this task, you will be required to find a set of simple statistics based on a given set of data. Data will be provided as an array of integers, and you will be tasked with finding the mean, median...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ denote the number of data points.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of integers.\n\n**Constraints**  \n$ n \\geq 1 $, and $ a_i \\in \\mathbb{Z}...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments