UVa : 11900 (Boiled Eggs)



// link: http://uva.onlinejudge.org/external/119/11900.html
// Runtime: 0.008s
// Tag: Adhoc

#include <cstdio>
#include <algorithm>

using namespace std;

int main ()
{
    int testCase; scanf ("%d", &testCase);
    int cases = 0;
    while ( testCase-- ) {
        int n, p, q; scanf ("%d %d %d", &n, &p, &q);
        int eggWeight [30 + 3];
        for ( int i  = 0; i < n; i++ ) scanf ("%d", &eggWeight [i]);
        sort (eggWeight, eggWeight + n);
        int cnt = 0;
        for ( int i = 0; i < min (p, n); i++ ) {
            q -= eggWeight [i];
            if ( q >= 0 ) cnt++;
        }
        
        printf ("Case %d: %d\n", ++cases, cnt);
    }
    
    return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s