034. Broken Ladder

Codeforces
IDCF10269034
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You have a broken ladder. Your ladder would normally have $n$ rungs numbered from 1 to $n$, but unfortunately some of the rungs have broken off. You can only climb up the ladder if the minimum gap between rungs is less than or equal to some value $k$. For example, if $k$ = 1, if the ladder was broken at all, you would not be able to climb the ladder. The first line of input contains two space-separated positive integers _n_ and _k_: the number of rungs remaining on the ladder, and the largest gap in rungs that you can climb over, respectively. The second line of input contains a sorted list of $n$ integers greater than or equal to 1: the positions of the rungs of the ladder. *You can assume that the first and last rungs of the ladder are not broken.* Output "YES" if you can still climb the broken ladder, otherwise "NO". (no quotes) ## Input The first line of input contains two space-separated positive integers _n_ and _k_: the number of rungs remaining on the ladder, and the largest gap in rungs that you can climb over, respectively. The second line of input contains a sorted list of $n$ integers greater than or equal to 1: the positions of the rungs of the ladder. *You can assume that the first and last rungs of the ladder are not broken.* ## Output Output "YES" if you can still climb the broken ladder, otherwise "NO". (no quotes) [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $ be the number of remaining rungs. Let $ k \in \mathbb{Z}^+ $ be the maximum allowable gap between consecutive rungs. Let $ A = (a_1, a_2, \dots, a_n) $ be a strictly increasing sequence of positive integers representing the positions of the remaining rungs, with $ a_1 = 1 $ and $ a_n $ being the top rung. **Constraints** 1. $ 1 \leq n \leq 100 $ 2. $ 1 \leq k \leq 100 $ 3. $ 1 = a_1 < a_2 < \dots < a_n \leq 100 $ **Objective** Determine whether $ \max_{1 \leq i < n} (a_{i+1} - a_i) \leq k $. If true, output "YES"; otherwise, output "NO".
API Response (JSON)
{
  "problem": {
    "name": "034. Broken Ladder",
    "description": {
      "content": "You have a broken ladder. Your ladder would normally have $n$ rungs numbered from 1 to $n$, but unfortunately some of the rungs have broken off. You can only climb up the ladder if the minimum gap bet",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269034"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You have a broken ladder. Your ladder would normally have $n$ rungs numbered from 1 to $n$, but unfortunately some of the rungs have broken off. You can only climb up the ladder if the minimum gap bet...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of remaining rungs.  \nLet $ k \\in \\mathbb{Z}^+ $ be the maximum allowable gap between consecutive rungs.  \nLet $ A = (a_1, a_2, \\dots, a_n) $...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments