Stuck in a problem named "The Lead Game"

Contest Page | CodeChef : this is the link for the problem.

Solution: 48361907 | CodeChef : this is a link to my solution. Code is getting compiled successfully but the answer is wrong. Can anyone please help me by telling me whats wrong in my code? Thanks :slight_smile:

Whole bunch of warnings (when compiled with clang) that you should fix first :slight_smile:

[~/devel/hackerrank/otherpeoples]>./ clang
Compiling atharva_u1-TLG.cpp
+ clang++ -std=c++14 -stdlib=libc++ atharva_u1-TLG.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_LIBCPP_DEBUG=1 -L/home/simon/devel/clang-git/install/lib/ -fsanitize=undefined,bounds,integer -ftrapv
atharva_u1-TLG.cpp:52:12: warning: variable 'w' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
        }else if( a[index] < 0 ) {
atharva_u1-TLG.cpp:56:8: note: uninitialized use occurs here
        cout<<w<<" "<<l;
atharva_u1-TLG.cpp:52:8: note: remove the 'if' if its condition is always true
        }else if( a[index] < 0 ) {
atharva_u1-TLG.cpp:47:7: note: initialize the variable 'w' to silence this warning
        int w ; 
              = 0
atharva_u1-TLG.cpp:23:8: warning: variable 't' is uninitialized when used here [-Wuninitialized]
        int a[t];
atharva_u1-TLG.cpp:21:14: note: initialize the variable 't' to silence this warning
        int test,s,t;
                     = 0
2 warnings generated.
+ set +x
1 Like

Thanks for replying! I’ll look into it.

1 Like

have a look at my code you might get something

1 Like

I didn’t really understand the concept of cumulative scores. But I got it now. Thanks!! :smile: