(KETFAST)Why i am getting WA?

Problem link–>https://www.codechef.com/problems/KETFAST

My Solution–>

import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class ketfast
{
public static void main(String[] args)
{

    Scanner sc=new Scanner(System.in);
    int t=sc.nextInt();
    while(t!=0)
    {        
        int ans=0;
    int skip=sc.nextInt();
     int cnt[]=new int[26];
     int hash[]=new int[26];  
     TreeMap<Integer,Integer> vk=new TreeMap();
      String alpha="abcdefghijklmnopqrstuvwxyz";

  for(int i=0;i<26;i++)
   {
       cnt[i]=sc.nextInt();
  }

   String type=sc.next();

for(int i=0;i<type.length();i++)
{

      hash[alpha.indexOf(type.charAt(i))]++;       

   }
  
 for(int i=0;i<type.length();i++)

{

  vk.put(cnt[alpha.indexOf(type.charAt(i))],hash[alpha.indexOf(type.charAt(i))]);         

 }
     
int last=vk.size();

int count=0;

while(skip!=count)
 {
      
     if(Integer.parseInt(vk.values().toArray()[last-1].toString())-1>=0)
     {


         vk.replace(Integer.parseInt(vk.keySet().toArray()      [last1].toString()),Integer.parseInt(vk.values().toArray()[last-1].toString())-1);         

           count++;
}
     else
         last--;
        
 }
for(Map.Entry m:vk.entrySet())
 ans=ans+(Integer.parseInt(m.getKey().toString())*Integer.parseInt(m.getValue().toString()));
           
          
        System.out.println(ans);
          
    t--;}
}

}
What is Wrong in this approach?

/this is my solution…hope this helps/

#include
using namespace std;
int main()
{
	int t;
	char a[11];
	scanf("%d",&t);
	while(t--)
	{
		int t,i,sum=0;
		scanf("%d",&t);
		
		int ti[26];
		for(i=0;i<26;i++)
		scanf("%d",&ti[i]);
		
		scanf("%s",a);
		int l=strlen(a);
		int c[l];
		for(i=0;i<l;i++)
		{
			int v=a[i]-97;
			c[i]=ti[v];
		}
		sort(c,c+l);
		
		for(i=0;i<l-t;i++)
		sum=sum+c[i];
		
		printf("%d\n",sum);
	}
	return 0;
}