洛谷題解【超級書架】
阿新 • • 發佈:2019-05-04
queue -- print tps sin 就是 for turn 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; }
洛谷題解【超級書架】