@[dongrq_cs](/user/644394) 从 $0$ 开始,不要从 $1$ 开始,输出时输出 $i + 1$。
改后的 $code$
```cpp
#include <bits/stdc++.h>
using namespace std;
bool cmp(int x,int y){
return x > y;
}
long long m,n,q[20000],ans = 0;
int main(){
cin >> n >> m;
for(int i = 0;i < n;i++){
cin >> q[i];
}
sort(q,q + n,cmp);
for(int i = 0;i < n;i++){
ans += q[i];
if(ans >= m){
cout << i + 1 << endl;
break;
}
}
return 0;
}
```
by Alan_wmx @ 2023-04-02 21:13:24
@[Alan0411](/user/686228)
谢!!!
要悬赏吗?
找 [Saint_ying_xtf](https://www.luogu.com.cn/user/852144)
by dongrq_cs @ 2023-04-02 21:16:28
@[dongrq_cs](/user/644394) 不用了,应该的。
by Alan_wmx @ 2023-04-02 21:20:08