Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
24338 | 老方 | 淘气的小明摘椰子 | C++ | Accepted | 0 MS | 244 KB | 419 | 2023-08-10 13:14:45 |
#include<bits/stdc++.h> using namespace std; int main(){ int high,n,h=160; cin>>high>>n; int ns[n]; for(int i=0;i<n;i++){ cin>>ns[i]; } for(int j=0;j<n;j++){ for(int i=0;i<5;i++){ if(ns[i]>ns[i+1]){ int t=ns[i]; ns[i]=ns[i+1]; ns[i+1]=t; } } } int i; for(i=0;i<n;i++){ if(h+ns[i]>=high){ cout<<i; break; } else{ h+=ns[i]; } } return 0; }