Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
435058 黄浙峰老师 【C6-7】加勒比海盗船 C++ 通过 100 2 MS 268 KB 369 2026-04-04 11:12:56

Tests(2/2):


#include<iostream> #include<algorithm> using namespace std; int main(){ int n,m,w[10005]; int c,t,ans; cin>>m; for(int i=0; i<m; i++){ cin>>c>>n; for(int j=0; j<n; j++){ cin>>w[j]; } 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; }


测评信息: