1
0

1004.cpp 483 B

1234567891011121314151617181920212223242526
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. using namespace std;
  5. int arr[20000];
  6. bool cmp(int a, int b) {
  7. return a > b;
  8. }
  9. int main() {
  10. int nCow, nShelfHeight;
  11. cin >> nCow >> nShelfHeight;
  12. for (int i = 0; i < nCow; ++i) {
  13. scanf("%d", arr+i);
  14. }
  15. sort(arr, arr+nCow, cmp);
  16. int nHeight = 0, result = 0;
  17. for (int i = 0; nHeight < nShelfHeight; ++i, ++result) {
  18. nHeight += arr[i];
  19. }
  20. cout << result;
  21. return 0;
  22. }