poj3627 水题

/*
Time:2019.12.2 
Author: Goven
type:水题 
err:
ref:
*/
#include
#include
using namespace std;

int h[20005];

bool cmp(int x, int y) {
    return x > y;
}

int main()
{
    int n, b;
    cin >> n >> b;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h, h+n, cmp);
    for (int i = 0; i < n; i++) {
        b -= h[i];
        if (b <= 0) {
            cout << i + 1 << endl;
            break;
        }
    }
    return 0;
}

你可能感兴趣的:(poj3627 水题)