Skyline Photo Help

Revision en1, by _w_, 2021-05-31 12:22:30

I was solving the 1482E - Skyline Photo, and it turns out to be WA. I am not sure why did this happen please help me out.

I have used a 2D dp array where dp[i][0] stores the maximum beauty that can be achieved if we combine ith building with the last building dp[i][1] stores the maximum beauty that can be achieved if put in a new photo

While storing the value in dp[i][0] I also took note that in some cases using dp[i-1][0] and dp[i-1][1] both may result with same beauty. So, I took the one that had the greater beauty for the smallest building in the last photo cause that will give a better solution if we happen to find a smaller building with better beauty.

for this "combine" I used a 2D mn_idx array that stores for each state the index of building with minimum height in the current photo ending at ith building.

I could not see the testcases, it shows WA on test 8. So is the logic completely wrong (it will be better if you could please explain why is that so?)?

Here is my code

Code

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English _w_ 2021-05-31 12:22:30 3116 Initial revision (published)