Learn DSADSAContests
coding75 logo
LeetCode POTDPOTDSheets
coding75 Pro
coding75 logo
Dashboard
Learn DSA
Course RoadmapFlow
DSA Topic TreeNew πŸš€
Contest SolutionsPractice
Practice Sheets
MasterclassesLive πŸ‘¨πŸ»β€πŸ’»

coding75 ProPRO

Live Classes & Placement Guidance

coding75 logo

The premier developer platform for mastering Data Structures & Algorithms, exploring contest editorials, building ATS-ready resumes, and accelerating your tech career.

Connect & Community

DSA & Contests

  • Learn DSA
  • Contest Solutions
  • LeetCode POTDDaily
  • Practice Sheets
  • MasterclassesSoon

Interview Prep

  • Portfolio Projects
  • CS Fundamentals
  • System DesignSoon
  • Interview ExperiencesSoon
  • Mock InterviewsSoon

Career & Pro

  • Jobs & Internships
  • Resume BuilderATS
  • coding75 Pro
  • Submit Feedback
Β© 2026coding75β€’crackDSAβ„’β€’Maa Lalita Edtech Private Limited. All Rights Reserved.
Privacy PolicyTerms & ConditionsContact Support
Registered Office: Kanpur 208021β€’Regional Office: Indiranagar, Bangalore, 560008
Maa Lalita Edtech Private Limited
Contests/CodeChef/Starters 137/Speedrun
Prev
CodeChefCodeChef
5 Star
Starters 137

Speedrun

ArraySuffix ArrayPrefix SumGreedy
Loading...
Solve on CodeChef

Problem Statement

Official algorithmic problem description and constraints.

Open on CodeChef

Chef is playing a computer game. There are π‘ monsters on the number line.


Chef is at position 0 on the number line. Initially, the ith monster has health equal to π»π‘–​ and is at the position π΄π‘–​ on the line.

It is guaranteed that π΄π‘–<𝐴𝑖+1​ for every 1≀𝑖<𝑁.

Every second, the following happens:

  • First, Chef can choose a single index i (1≀𝑖≀𝑁) such that the π‘–π‘‘β„Ž monster is still alive, and fire one bullet at it. This reduces π»π‘–​ by 1.
  • Then, all alive monsters whose health is 0 will die.
  • Finally, all alive monsters move one position closer to Chef.

If any monster reaches position 0, Chef loses.

If Chef manages to kill all the monsters before any of them reach position 0, he wins.

Before the start of the game, Chef can plant a bomb at any position on the line.

If the bomb is placed at position π‘‹, all monsters whose starting positions lie between π‘‹βˆ’𝐾 and π‘‹+𝐾 will die immediately, and the game will start with the remaining monsters.

If Chef places the bomb optimally, can he win the game?

Solutions & Walkthrough

Detailed video explanations, mathematical intuition, and clean C++ implementation code.

Connecting secure classroom stream...
Back to Starters 137
Previous Problem