I was solving the problem 607A - Цепная реакция and got WA on test case 11. Here's my submission 82317236. dp[i] is basically the number of destroyed beacons if we consider the coordinates [0,i]
. numBeacons[i] is the total number of beacons again in [0,i]
. Please help me where I am wrong. Have been stuck in this problem for a while now.
try initializing ii by
int ii = numBeacons[0];
instead of havingint ii = 0;
since your loop that is evaluating the dp starts from 1 in cases where initial poisition of some Beacon is 0 the powers are being shifted (as ii is still 0). i.e. the instead of power of Beacon 1 power of Beacon 0 is being used and so on.
Example test case:
Actual ans : 2
Your Output : 3
Thank you so much man! I knew I had made some silly mistake but couldn't figure it out.