865A: Save the problem!

Official solution: suppose we have only denomination 1 and 2, then given amount A, we have only A/2 + 1 ways to form the number, because the only replace we can do is replace 2 1s with a 2

This is way quicker than my reverse dp approach during the contest!!!

865B: Ordering Pizza

I tried a double pointer approach, and it gave me TLE!!! very likely because I put # of pizzas in an infinite loop.

Official solution:

To simplify implementation, we add another dummy people that reads all leftover pieces without gaining any happiness Also, there is at most one pizza shared by people preferring different types. So there are potential 2 cases, 1 for each type of pizza. We just try both and pick the better one

865D: Buy Low Sell High

Everyday, we gain one option to buy, and if today’s price is higher than some options price, we know we can sell some options at that price, but we don’t know if it is the best time to sell, so we can just sell and give us options to buy back at the price we sell. This transformation works because on a day we do nothing <=> selling and buying on the same day.