(int i, int d, int cur_max, int[] jobDiff)
| 9 | } |
| 10 | |
| 11 | private int dfs(int i, int d, int cur_max, int[] jobDiff){ |
| 12 | if(i == jobDiff.length) |
| 13 | return (d == 0)? 0: (int)1e9; |
| 14 | if(d == 0) |
| 15 | return (int)1e9; |
| 16 | String cur_state = i + "," + d + "," + cur_max; |
| 17 | if(cache.containsKey(cur_state)) |
| 18 | return cache.get(cur_state); |
| 19 | |
| 20 | cur_max = Math.max(cur_max, jobDiff[i]); |
| 21 | int res = Math.min( |
| 22 | dfs(i + 1, d, cur_max, jobDiff), |
| 23 | cur_max + dfs(i + 1, d - 1, -1, jobDiff) |
| 24 | ); |
| 25 | cache.put(cur_state, res); |
| 26 | return res; |
| 27 | } |
| 28 | } |
no test coverage detected