http://codeforces.com/contest/1185/problem/C2
桶排序,今年栽在桶排序上已经有两次了,果然是基础不行
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int N,M,x,t[105],ans,qian;
int main()
{
memset(t,0,sizeof(t));
scanf("%d%d",&N,&M);
while(N--)
{
scanf("%d",&x);
ans=0;
int k=qian-M+x;
for(int i=100;k>0&&i>=1;i--)
{
int sum=i*t[i];
if(sum>=k)
{
ans+=(k+i-1)/i;
break;
}
ans+=t[i];
k-=sum;
}
qian+=x;
t[x]++;
printf("%d ",ans);
}
return 0;
}