OpenAIOA #10
Maximize The Hits
估计困难评测数据准备中,可先阅读题面
We have a number line and there are walls provided at coordinates x+0.5, where x is any integer. Each wall has some thickness to it. The player starts from x = 0 and every time they take a step to the left or right, they are exerting energy of 1 unit. However, when they go through a wall of thickness t, they are exerting energy of t units. You are also given the maximum energy you can spend in the whole simulation. The main goal of this algorithm is to return the maximum number of walls you can hit. (After you hit the wall it still exists so you can keep going back and forth to hit the same wall). You can also go left and right at any point in time.
NOTE: You always start from x - 0 :)
Function Description
Complete the function maximizeTheHits in the editor.
maximizeTheHits has the following parameters:
-
int[] walls: an array of integers representing the positions of the walls
-
int[] thickness: an array of integers representing the thickness of each wall
-
int energy: the maximum energy you can spend Returnsint: the maximum number of walls you can hit