Problem 4: Financial Planning
https://open.kattis.com/problems/financialplanning
Given an integer representing the number of days elapsed, we can determine the total profit following the optimal investment strategy. This involves only choosing investments that bring in a net profit after days. We can do this by thinking of each investment option as a linear function of the form , where is the net profit (or loss).
We want to find the earliest day so that the profit following the optimal investment strategy is at least .
We can compute the profit following the optimal investment strategy for onwards and take the first whose profit is at least . However this is too slow.
If is not a day where the profit following the optimal investment strategy is at least , then all days before do not have profits reaching.
However, if is a day where the profit following the optimal investment strategy is at least , then all days after can't be the earliest day with profits of at least .
Therefore, we can find the earliest day using binary search.
Last updated