May challenge CORUS

this is the code to may challenge 2020,
code:CORUS,I don’t know what’s wrong with it,it seems to be correct but codechef is showing wrong answer

import java.io.;
import java.util.
;
class isocen
{
public static void main(String a[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0){
int n=sc.nextInt();
int q=sc.nextInt();
sc.hasNext();
String s =sc.next();

		int r=0,count,i=0,j=0,s1=0,val=0;
		
		s=s.toLowerCase();
			char string[] = s.toCharArray();  
      		int l=string.length;
      		int arr[]=new int[l];
      		
      		

    for(i = 0; i<l; i++) 
{  
        count = 1;  
        for(j = i+1; j<l; j++) {  
            if(string[i] != '0' && string[i] == string[j]  ) {  
                count++;  
                  
                string[j] = '0';  
            }  
        }  
     arr[i]=count;
     
}



	while(r<q)
	{
	int q1=sc.nextInt();
	for(i=0;i<l;i++)
	{
	val=arr[i];
	
	 if(arr[i]>=q1)
		{
		val=val-q1;
		    
		s1=s1+val;
		    
		}
	
	
	}
	System.out.println(s1);
	s1=0;
	r++;
	}

t–;
}
}
}

‘’'import java.io.;
import java.util.
;
class isocen
{
public static void main(String a[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
try {
while(t>0){
int n=sc.nextInt();
int q=sc.nextInt();
sc.hasNext();
String s =sc.next();

	int r=0,count,i=0,j=0,s1=0,val=0;
	
	s=s.toLowerCase();
		char string[] = s.toCharArray();  
  		int l=string.length;
  		int arr[]=new int[l];
  		
  		

for(i = 0; i<l; i++) 

{
count = 1;
for(j = i+1; j<l; j++) {
if(string[i] != ‘0’ && string[i] == string[j] ) {
count++;

            string[j] = '0';  
        }  
    }  
 arr[i]=count;

}

while(r<q)
{
int q1=sc.nextInt();
for(i=0;i<l;i++)
{
val=arr[i];

 if(arr[i]>=q1)
	{
	val=val-q1;
	    
	s1=s1+val;
	    
	}


}
System.out.println(s1);
s1=0;
r++;
}

t–;
}
}
catch(Exception e)
{
return ;
}
}
}‘’’

I also don’t know why the soln is not accepted.it is 100% okk by some changes