-
Notifications
You must be signed in to change notification settings - Fork 0
/
1185C2.cpp
41 lines (34 loc) · 872 Bytes
/
1185C2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
int a[n];
int b[n];
int x=0;
for(int i=0;i<n;i++){cin>>a[i];b[i]=a[i]+x;x=b[i];}
int p[109]={0};
for(int i=0;i<n;i++){
if(b[i]<=m){
cout<<0<<" ";
}
else{
int z=0;
for(int i1=100;i1>=0;i1--){
if(p[i1]){
if(p[i1]*i1<(b[i]-m)){
b[i]-=(p[i1]*i1);
z+=p[i1];
}
else{
int x=ceil((b[i]-m)/float(i1));
cout<<z+x<<" " ;
break;
}
// cout<<b[i]<<" "<<a[i]<<"\n";
}
}
}
p[a[i]]++;
}
}