Jump Game
Time limit3sMemory limit1024 MB
Given N platforms whose values come from Q range-increment operations, choose jump positions at least K apart to maximize the sum of their values.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Segment tree, Intervals
- Solved
- No attempts yet
Problem
KOI Corp's jump game asks the player to cross platforms arranged in a row, using several jumps. The platforms sit on a vertical line and are numbered from left to right. At the start, the player stands on platform 0, the leftmost one, with a score of 0.
For every , the player chooses either walk or jump on platform . Walking moves the player to platform and leaves the score unchanged. Jumping moves the player to platform and increases the score by , where is a fixed number. The game ends successfully once the player moves past platform . Platforms numbered do not exist, but reaching any of them counts as moving past platform . The goal is to steer the player so that the final score is as large as possible and the game ends.
The KOI developers could not design so many platforms by hand, so they built them with a simple method. They set every to 0, then perform operations. For each (), they choose an interval and increase each of by 1. After all operations, the array gives the score earned by jumping from each platform.
You are making a video about computer science that explains how to finish the KOI jump game with the maximum score. The game has up to platforms, so you need an efficient algorithm.
Constraints
- For all ,