Hi everyone I'm really new here and I gave a try for the first problem of 
Kickstart 2020.
I get WA, but when I give my tests set, it gives good answers, here is my 
code:

public class Ej1 
{

    
    public static void main(String[] args) 
    {
        int t,n,b,value,n_casas;
        Scanner S= new Scanner(System.in);
        
        t=S.nextInt();
        
        int cases[]= new int[t];
        for(int i=0;i<t;i++)
        {
            n=S.nextInt();
            b=S.nextInt();
            
            int a[] = new int [n];
            
            for(int j=0;j<n;j++)
            {
                value=S.nextInt();
                a[j]=value;
            }
            
            
             n_casas=contadorCasas(a,b);  
             
             cases[i]=n_casas;
             
        }
        
        for(int i =0;i<t;i++)
            System.out.println("Case#"+(i+1)+":"+cases[i]);
        
    }
    
    
    static int contadorCasas(int v[], int b)
    {
        int aux=v[0];
        int counter=0;
        minimoVec(v);
        
        
        if(aux<b)
        {
            counter++;
            for(int i =1;i<v.length;i++)
            {
                if(aux+v[i]<b)
                {
                    aux+=v[i];
                    counter++;
                }
            }
        }
        
        
        return counter;
    }
    
    static void minimoVec(int vec[])
    {
        int min=vec[0];
        int aux;
        
        for (int x = 0; x < vec.length; x++) {
            for (int i = 0; i < vec.length-x-1; i++) {
                if(vec[i] < vec[i+1]){
                    int tmp = vec[i+1];
                    vec[i+1] = vec[i];
                    vec[i] = tmp;
            }   
        }
    }
        
        
    }
    
} 

I'm new so I'm really receptive for ideas.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/1203ee4f-018e-4ff7-bc80-63e611430d4a%40googlegroups.com.

Reply via email to