Help with codeforces question

My code when k=421654016 ran into RE plz help why it is showing so…,

problem link: Problem - 1368B - Codeforces

my solution link: Submission #84649083 - Codeforces

Thanks

int A[10];
x=ceil(log2(k));
for(i=0;i<x;i++) {
    A[i]++;
}

x comes to be 28. Array is of 10 elements.
You can’t access A[i] when i is greater than 9.

For the given k, your x reaches 28 while the array initialized by you has only memory for 10 integers. Hence, the RE.

Thanks got it

1 Like