On yesterday's div3F, i've seen multiple solutions detailing this. 1872F - Selling a Menagerie
- Let's model it as how much index i get's affected if we sell i right now.
- Maintain it in a set.
- Always sell the index i that is least affected.
I get that we should always sell an index i that such that for all j, no Aj = i,
However, when there are some Aj = i, why is it optimal to sell the one that get's affected the least?
- How can we prove it's optimal
- Is it ever possible to sell another thing that is currently afraid of the minimum, thereby decreasing the minimum more, such that the sum of all affected will in fact be less.
Implementation details here. 222332183
Thanks for the help everyone!