大佬们请看最后几行break前的那个输出,为啥我加一才能过?
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n;
int crow[20001];
unsigned long long high,total=0;
cin >> n>>high;
for (int i = 1; i <= n; i++)
{
scanf("%d", &crow[i]);
}
sort(crow + 1, crow + n + 1);
for (int i = n; i >= 1; i--)
{
total += crow[i];
if (total >= high) {
cout << n+1 - i;
break;
}
}
return 0;
}