| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 76787 | sh25_shenpy | 小明摘椰子 | C++ | 通过 | 0 MS | 248 KB | 462 | 2025-12-19 19:07:17 |
#include <bits/stdc++.h> #include<algorithm> #include<functional> using namespace std; int s[1011]; int main() { int n,h,m,d=0,k=0,w=0; cin>>h; cin>>n; for(int i=0;i<n;++i){ cin>>s[i]; } sort(s,s+n,greater<int>()); for(int x:s) { d+=x; k++; if(d+160>=h){ cout<<k; break;}} for(int y=0;y<n;++y){ w+=s[y];} if(w+160<h) cout<<"-1"; return 0; }