Covid problem shows me tle. Please tell me what can i do in this case!

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>

int validOrNot(int array[],int spotCount); // prototype of validOrNot function

int main(int argc, char** argv) {
int testCase,spotCount,ans;
int queueArray = (int)malloc(sizeof(int)*spotCount);

scanf("%d %d",&testCase,&spotCount);

for (int i = 0; i < testCase;i++) {
	for(int j = 0; j < spotCount; j++) {

		scanf("%d",&queueArray[j]);	
	}
	
	// debugging portion

// printf(“Debugging the actuall array value: “);
// for(int itter = 0; itter <spotCount;itter++) printf(”%d\t”,queueArray[itter]);
// printf("\n");
// Debugging portion

	ans = validOrNot(queueArray,spotCount); // Validating the array for yes or no

	if (ans == 1) printf("Yes\n");
	else printf("No\n");
	scanf("%d",&spotCount);

}
return 0;

}

int validOrNot(int array,int spotCount) {
int count = 0,oneCount = 0;
/
printf("\nWorking for array : “);
for(int i =0 ; i < spotCount;i++) {
printf(”%d",array[i]);
}
printf("\n");*/

for (int i = 0; i < spotCount; i++) {
	if (array[i] == 1) oneCount++;
	else continue;
}

/* if (oneCount > 2) {
printf("\nThere are more than 2 one is exist!! Be carefull\n");
}*/

for (int i = 0; i < spotCount;i++) {
	if (array[i] == 1) {

// count = 0;
++count;
} else if (oneCount > 2) {
count = 0;
++count;

	} 
	else {
		if(array[i+1] < 1) count++;
		

	}
}
//printf("\nValue of count is : %d",count);
if(count >= 6) {
	return 1;
} else if (count < 6) {
	return -1;
}

}

Sorry I don’t have any idea how the editor works. So I have made a mistake by doubling the ans… I hope you guys will forgive me for this.

You can definetly check my solution for the same problem :upside_down_face:

#include<bits/stdc++.h>//author::@whohet-->Het Patel
#define int long long

using namespace std;


signed main()
{
	//initialize();
	//fasterthanlight;
	int t;
	cin>>t;
	for(int v=0;v<t;v++)
	{
		int n;
		cin>>n;
		int arr[n];
		int t=0,flagfirst=1,flag=1,gap=0;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
		}
		for(int i=0;i<n;i++)
		{
			if(arr[i]==1 && flagfirst==1)
			{
				flagfirst=0;gap=0;
			}
			else if(arr[i]==1 && flagfirst==0)
			{
				if(gap<5)
					flag=0;

				gap=0;
			}
			else if(arr[i]==0)
				gap=gap+1;
			

		}
		if(flag==0)
			cout<<"NO\n";
		else
			cout<<"YES\n";
	}

	return 0;
}

Run time error :smiley: :smiley: :smile:

No, it works fine

1 Like

it is working fine

https://www.codechef.com/viewsolution/32133758
Check this solution link if you think so.

You should have atleast mentioned the problem url.