@aniket20 Please look into my solution which I submitted within 10 minutes of the start of the contest which showed wrong answer, I looked into other solutions , they are same as well. https://www.codechef.com/viewsolution/8585974
The only modification is i am filling all array as zero in second one (kinda static binding). But whats the reason for first to not work? Elements of the array from 0 to n-1 are already being read from input so it shouldn’t have any problem?