Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
436117 顾鑫辰 【C6-7】加勒比海盗船 C++ 通过 100 1 MS 260 KB 418 2026-04-11 19:19:45

Tests(2/2):


#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; }


测评信息: