events
by start time.dp
for memoization.dfs(cur_index, count)
.
dp
.count
is 0 or cur_index
is out of bounds, return 0.skip_value = dfs(cur_index + 1, count)
.next_index
of the nearest event that can be attended after cur_index
.attend_value = events[cur_index][2] + dfs(next_index, count - 1)
.skip_value
and attend_value
in dp[count][cur_index]
.dfs(0, k)
.