Smiley- All custom test cases give the correct answer, but on submitting all test cases fail

My issue

My code

#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d", &t);
	
	for (t;t>0;t--){
	    int n;
	    scanf("%d", &n);
	    char arr[n];
	    int colon[n];
	    int cc=0;
	    int sadc=0;
	    int happyc=0;
	    int ans=0;
	    
	    for (int c=0; c<n+1;c++){
	        scanf("%c", &arr[c]);
	        if (arr[c]==':'){
	            colon[cc]=c;
	            cc+=1;
	        }
	    }
	    for(int c=0;c<cc-1;c++){
	        sadc=0;
	        happyc=0;
	        for (int l=colon[c]+1; l<colon[c+1];l++){
	            if (arr[l]==')'){
	                happyc+=1;
	            }
	            else{
	                sadc+=1;
	            }
	        }
	        if (sadc == 0 && happyc>0){
	            ans+=1;
	        }
	    }
	    for (int j=colon[cc-1];j<=n;j++){
	        sadc = 0;
	        happyc = 0;
	        if (arr[j]==')'){
	            happyc+=1;
	        }
	        else{
	            sadc+=1;
	        }
	        
	    }
	    if (sadc == 0 && happyc>0){
	            ans+=1;
	        }
	    
	    printf("%d \n", ans);
	}
	return 0;
}


Problem Link: SMILEY Problem - CodeChef