| Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|
| 57413 | zhangweiran | 小明摘椰子 | C++ | Accepted | 0 MS | 244 KB | 437 | 2024-11-22 15:47:18 |
#include <algorithm> #include <iostream> using namespace std; int main(){ int n,ye; //ye椰子树高度,n木箱个数 cin>>ye>>n; int a[100]; for(int i=0;i<n;i++){ cin>>a[i]; } //输入n个箱子高度 sort(a,a+n); int sum=0; int min=n; for(int i=0;i<n;i++){ sum+=a[i]; if(sum>ye-160){ if(i<min){ min=i; } } } if(sum<ye-160){ cout<<-1; }else{ cout<<min; } return 0; }