#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int allocate(vector<int> A, int B)
{
    
    sort(A.begin(), A.end());
    int count = 0;
    for(int i = 0; i< A.size() -1; i++)
    {
        if(B >= A[i])
        {
            //cout<<A[i]<<" "<<B<<endl;
            count++;
            B -= A[i];
            
        }
    }
    return count;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int nt; //number of test case
    int N, B;
    vector<int> A;
    
    //fstream fin("input.txt");
    

    //getline(fin, line);
    
    //stringstream ss;
    //ss.str(line);
        
    cin>>nt;

    for(int i = 1;i <= nt; i++)
    {
        
        cin>>N>>B;
        //cout<<N<<" "<<B<<endl;

        for(int j = 0; j<N; j++)
        {
            int a;
            cin>>a;
            //cout<<a<<" ";
            A.push_back(a);
        }

        cout<<"Case #"<<i<<": "<<allocate(A,B)<<endl;
        A.clear();
    }
    
    return 0;
}

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/3dc2e8db-45fa-48e7-8b91-701198ffc4ee%40googlegroups.com.

Reply via email to