| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 435131 | 王栎州 | 【C6-7】加勒比海盗船 | C++ | 通过 | 100 | 3 MS | 264 KB | 418 | 2026-04-04 13:38:52 |
#include<bits/stdc++.h> using namespace std; int n,a[10086],m,c,s; int main(){ cin>>m; for(int i=1;i<=m;i++){ s=0; cin>>c>>n; for(int j=1;j<=n;j++){ cin>>a[j]; } sort(a+1,a+n+1); for(int k=1;c>0;k++){ c-=a[k]; s++; if(k==n){ break; } } if(s==n){ cout<<s; }else{ cout<<s-1<<endl; } } return 0; }