Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
76708 sh25_shenpy 淘气的小明摘椰子 C++ 解答错误 0 MS 264 KB 474 2025-12-19 15:48:28

Tests(0/1):


#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; m=sizeof(s)/sizeof(s[0]); for(int i=0;i<m;++i){ cin>>s[i]; } sort(s,s+m,greater<int>()); for(int x:s) { d+=x; k++; if(d>=h){ cout<<k; break;}} for(int y:s){ w+=y;} if(w<h) cout<<"-1"; return 0; }


测评信息: