Giving wrong answer despite getting the right results

Problem Code:WALKFAST
Here is my solution to the above given problem
https://www.codechef.com/viewsolution/45032858

I have analyzed the problem so many times and tried to make the solution better and I am getting the correct results but when I click on submit, it is giving me wrong answer!!
Please help me!

I have analyzed different test cases and I am getting correct output when I click the run button

Pay attention to compiler warnings!

[simon@simon-laptop][12:17:52]
[~/tmp/DONTSYNC/hackerrank/otherpeoples]>./compile-latest-cpp.sh 
Compiling abhi_rex1-WALKFAST.cpp
+ g++ -std=c++14 abhi_rex1-WALKFAST.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
abhi_rex1-WALKFAST.cpp: In function ‘int main()’:
abhi_rex1-WALKFAST.cpp:27:25: warning: ‘d2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         count1 = (abs(d2-d1))*(p);
                       ~~^~~
abhi_rex1-WALKFAST.cpp:27:25: warning: ‘d1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
+ set +x
Successful

Your solution gives me a different answer every time for the following test input:

1
5 5 3 4 2 58 72 72
-65 -64 -61 -29 92
4 Likes

Okay Thanks
I’ll check it out

1 Like

Thank You @ssjgz !!
It was really helpful … I have done some changes in the code accordingly …Now I am getting the result as correct answer… Thank you so much!

1 Like