原题传送门spa
无
大家无耻的水题垲又回来了!!!(最近作题有点不顺,刷刷水题找找自信)。
认真点,好吧,思路就是桶排,而后从大到小选择奶牛(实际上运用了贪心的思想,易证(就是懒得证))。code
#include<cstdio> #include<queue> using namespace std; int t[10001]; int main() { int n,h,hi,i,ans=0; scanf("%d %d",&n,&h); for (i=0;i<n;i++) scanf("%d",&hi),t[hi]++; for (i=10000;h>0;i--) { if (i*t[i]<=h) h-=i*t[i],ans+=t[i]; else { ans+=h/i+1; break; } } printf("%d",ans); return 0; }