Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
76657 sh25_shenpy 淘气的小明摘椰子 C++ 编译错误 0 MS 0 KB 436 2025-12-19 15:42:27

Tests(0/0):


#include <bits/stdc++.h> #include<algorithm> #include<functional> using namespace std; int n; int s[n]; int main() { int h,m,d=0,k=0; cin>>h; cin>>n; for(int i=0;i<n;++i){ cin>>s[i]; } m=sizeof(s)/sizeof(s[0]); sort(s,s+m,greater<int>()); for(int x:s) { d+=x; k++; if(d>=h){ cout<<k; break;} if(d<h) cout<<"-1"; return 0; }


测评信息: