Https://www.codechef.com/viewsolution/54841639

https://www.codechef.com/viewsolution/54841639

please help me whats the problem in this code

There’s an out-of-bounds access whenever K=N.

O shit this was tha first case i thought but i forgot to code thanks a lot man thank you thank you thank you so much God bless you

1 Like

Re: Solution: 54843964 | CodeChef - pay attention to compiler warnings!

[simon@simon-laptop][16:51:37]
[~/devel/hackerrank/otherpeoples]>  g++ -std=c++17 akashagarwal00-PROC18A.cpp -O3 -g3 -Wall -Wextra 
akashagarwal00-PROC18A.cpp: In function ‘int main()’:
akashagarwal00-PROC18A.cpp:16:24: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   16 |         int n,k,i,temp,ans;
      |                        ^~~