TLE in Uncle johny

iam getting time limit exceded…for this question…JOHNY Problem - CodeChef
and here is my answer code…CodeChef: Practical coding for everyone

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