why do i get wrong answers?

My pc ran this code but in codechef it’s showing wrong answer. Can someone tell me what’s wrong?
Here’s the link to question

Here’s the link to my solution

There are two mistakes you have made…

  1. you need to initialize d for each test case…
  2. for(i=0;i<c;i++)
    Here you need to use c - 1…instead of c as you are using i + 1 inside the loop.
    for more information see solution : https://www.codechef.com/viewsolution/18639155

this solution is same as yours after fixing above two issues.


Thats not a link to your code or any code.

Here is her solution @akki2200

Correct answer :slight_smile: