Algorithm · ByteDance · Medium
A lake region contains N fishing ponds. The array M gives the hourly catch available right now at each pond, so M[i] fish can be taken in an hour spent at pond i. You have K hours of fishing time in total, and at the start of every hour you may pick whichever pond you like. Each hour spent at a pond lowers that pond's yield by 1 for the next time it is picked. Ponds you skip keep their current yields. Compute the largest total number of fish you can bring in. Additional…