Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
332172 黄浙峰老师 【C6-7】加勒比海盗船 C++ 通过 100 3 MS 260 KB 463 2025-07-14 10:54:23

Tests(2/2):


#include<iostream> #include<algorithm> using namespace std; int main(){ int n,m,w[10005]; int c,t,ans; cin>>m;//m组测试数据。 for(int i=0; i<m; i++){ cin>>c>>n; for(int j=0; j<n; j++){ cin>>w[j]; }//把n个古董的重量从小到大排序 sort(w,w+n); t=0,ans=0; for(int k=0; k<n; k++){ t=t+w[k]; //选取古董 //未装满 if(t<=c) ans++; else break; } cout<<ans<<endl; } return 0; }


测评信息: