187. Mountain Biking

Codeforces
IDCF10269187
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You just went on a very hilly bike ride, and you want to find largest hill that you biked up during your ride. You know the elevations of several points along your ride, and you want to find the vertical rise of the largest continously uphill section of the ride. A continuously uphill section must have a positive overall vertical rise, and must consist of only uphill segments. If a section of the ride has any downhill or flat subsections, it is not considered a continuously uphill section. The first line of input contains a single positive integer $n$: the number of points along the ride that you know the elevations for. The next line contains $n$ space-separated integers: the elevation, along each point of the ride. Output a single positive integer $v$: the value of the biggest hill on the ride, defined as the vertical rise of the largest continiously uphill section, as defined above. There is guaranteed to be at least one continously uphill section in the route given in the input. ## Input The first line of input contains a single positive integer $n$: the number of points along the ride that you know the elevations for.The next line contains $n$ space-separated integers: the elevation, along each point of the ride. ## Output Output a single positive integer $v$: the value of the biggest hill on the ride, defined as the vertical rise of the largest continiously uphill section, as defined above. There is guaranteed to be at least one continously uphill section in the route given in the input. [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $ be the number of elevation points. Let $ E = (e_1, e_2, \dots, e_n) $ be a sequence of integers representing elevations at consecutive points along the ride. **Constraints** 1. $ n \geq 2 $ 2. $ e_i \in \mathbb{Z} $ for all $ i \in \{1, \dots, n\} $ 3. There exists at least one continuously uphill section. **Objective** Find the maximum vertical rise over any contiguous subsequence $ (e_i, e_{i+1}, \dots, e_j) $ where $ 1 \leq i < j \leq n $ and $ e_k < e_{k+1} $ for all $ k \in \{i, i+1, \dots, j-1\} $. That is, compute: $$ \max_{\substack{1 \leq i < j \leq n \\ e_k < e_{k+1} \, \forall k \in [i,j-1]}} (e_j - e_i) $$
API Response (JSON)
{
  "problem": {
    "name": "187. Mountain Biking",
    "description": {
      "content": "You just went on a very hilly bike ride, and you want to find largest hill that you biked up during your ride. You know the elevations of several points along your ride, and you want to find the vert",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269187"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You just went on a very hilly bike ride, and you want to find largest hill that you biked up during your ride.\n\nYou know the elevations of several points along your ride, and you want to find the vert...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of elevation points.  \nLet $ E = (e_1, e_2, \\dots, e_n) $ be a sequence of integers representing elevations at consecutive points along the r...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments