DDR Stamina Management
InterviewTime limit1sMemory limit1024 MB
Choose which sections to play so total points are maximized, where stamina recovers by K before each section (capped at 100) and playing costs h_i stamina.
- Level
Medium4 of 10
- Topics
- Dynamic programming, Implementation
- Solved
- No attempts yet
Problem
Coderbak, a rhythm gamer, has recently been hooked on Dance Dance Revolution (DDR). In this game, the player steps on pads in time with notes that fall while the song plays. The game drains a lot of stamina, so managing stamina matters a great deal.
The song has sections. For each section , Coderbak can choose to play it or skip it. Playing section earns points and costs stamina. Skipping a section earns no points and costs no stamina.
When the song starts, Coderbak has stamina. Before entering each section, his stamina recovers by . This recovery happens whether he plays or skips the section. If the stamina after recovery exceeds , it becomes . If playing a section would drop his stamina below , Coderbak must skip that section.
After a full day of DDR, Coderbak is exhausted and can no longer make decisions about managing his stamina. Write a program that outputs the maximum score he can earn so that he can still perform well.
Game over and other systems not mentioned in this statement are not considered in this problem.
Input
The first line contains two integers and , separated by a space. is the total number of sections in the song, and is the amount of stamina recovered.
The second line contains integers , separated by spaces.
The third line contains integers , separated by spaces.
Output
Print the maximum score Coderbak can earn.