haechandev
Algorithms

[Baekjoon 1516] Game Development

A dependency DP that memoizes the latest completion time among prerequisite buildings.

January 14, 2023

A building can have several prerequisites, and those prerequisites can be built in parallel. Its completion time is therefore the maximum prerequisite completion time plus its own construction time, rather than the sum of every prerequisite.

finish(building) = buildTime(building)
                  + max(finish(prerequisite))

I recursively computed prerequisites first and stored finished results in dp. Although the traversal follows a dependency graph, it is also DP because each node retains its final completion time for reuse.

Problem: Baekjoon · Code: View on GitHub