Help with problem

code: https://ide.codingblocks.com/s/470290
problem: https://atcoder.jp/contests/dp/tasks/dp_b

please tell where my logic is not correct

hello @raghav007

ur arr.size() never changes.
so use one variable to keep track of ur current location. and from their u can take atmost k steps.
also u have stored values in array from 0 index onwards but u r accessing it by 1 based indexing

I’m not able to figure out this part can you please show me the code snippet where I’m doing this, is it because of the push back function?

u are pushing element in ur vector so it will be stored based on 0 based indexing.

and here u are using 1 based indexinf to access the array value