You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
494 B
24 lines
494 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
const int N = 20010;
|
|
int a[N];
|
|
|
|
|
|
int main() {
|
|
int n, b;
|
|
cin >> n >> b;//b是书架的高度
|
|
for (int i = 1; i <= n; i++) cin >> a[i];//每头牛的身高
|
|
//按身高排序.从大到小
|
|
sort(a + 1, a + 1 + n, greater<int>());
|
|
|
|
int s = 0;//累加和
|
|
for (int i = 1;; i++) {
|
|
s += a[i];
|
|
if (s >= b) {
|
|
cout << i << endl;
|
|
exit(0);
|
|
}
|
|
}
|
|
return 0;
|
|
} |