TLE in Uncle johny

iam getting time limit exceded…for this question…https://www.codechef.com/problems/JOHNY
and here is my answer code…https://www.codechef.com/submit/JOHNY

Wrong link - that’s not a link to a solution :slight_smile:

Edit:

Here’s the correct link.

Edit2:

Here’s one problem:

        int s[n];
        for(i=1;i<=n;i++)
        {
            scanf("%d",&s[i]);
        }

That’s an out-of-bounds access (C arrays are 0-relative, remember).

Edit3:

You’re also not decrementing t anywhere.

1 Like