PROXYC - The base case runs but my code is not accepted why?

#include <stdio.h>
int main(void) {

	int c,l;
	scanf("%d",&c);
	if(c>=1&&c<=200)
    {
        int copy=c;
        int arr[c];
        while(c>0)
        {
            scanf("%d",&l);
            if(l>=1&&l<=1000)
            {
                char s[l];
                getchar();
                gets(s);
                if(check(s,l))
                {
                    int p=0,flag=0,i=0,j=2;
                    for(i=0;i<l;i++)
                    {
                        if(s[i]=='P')
                            p++;
                    }
                    while(((float)p/l)<(0.75))
                    {
                        int flag2=0;
                        for(i=j;i<l-2;i++)
                        {
                            if((s[i-2]=='P'||s[i-1]=='P')&&(s[i+1]=='P'||s[i+2]=='P'))
                            {
                                p++;
                                j=i+1;
                                flag2=1;
                                break;
                            }
                        }
                        if(flag2)
                            flag++;
                        else
                        {
                            flag=-1;
                            break;
                        }
                    }
                    arr[c-1]=flag;
                    c--;
                }
                else
                {
                    arr[c-1]=-2;
                    c--;
                }
            }
            else
            {
                arr[c-1]=-2;
                    c--;
            }
        }
        for(c=copy;c>0;c--)
        {
            if(arr[c-1]!=-2)
                printf("%d\n",arr[c-1]);
            else
                printf("Wrong input");
        }
    }
    else
        printf("Wrong input");
  return 0;

}
int check(char input[],int length)
{
int x=0,y=0;
for(int i=0;i<length;i++)
{
if(input[i]==‘P’)
x++;
else if(input[i]==‘A’)
y++;
}
if((x+y)==length)
return 1;
else
return 0;
}

@laraibaa5

Some points I want to say, the constraints of a problem are a restriction which setters have already provided to their inputs, it is not something which we need to check.

I did not get the point why you maintained an array.

You are not considering the character which is present at the ith position , i.e. in both the cases “PPAPP” and “PPPPP” your code will run the check whereas it only requires in the first case.

Thank you.

The input is all at once with no room for output after every sequence so i thought to create an array which would store my outputs and finally i would print every output using it.

I had to insert all those check points just so that my code is accepted.
Thanks for the test case.

Actually there are two steams of data, the input and the output stream. The input is fed to your code by input stream and the output of your code gets into the output stream. The answer is judged by your output stream of data only. So, no need of using arrays.

Oh didnt know about this, used to the terminal window xd. Thanx for the help and plz tell me why is this not accepted.

Last paragraph of my first reply

Thanx for the help,really appreciate it.