Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int c[101];
- int main()
- {
- int n, m, a;
- scanf("%d %d", &n, &m);
- int sumaTotal = 0;
- int perdieron = 0;
- for(int i=0; i<n; i++)
- {
- scanf("%d", &a);
- sumaTotal += a;
- int t = 100;
- while(sumaTotal > m)
- {
- while(c[t] == 0)
- t--;
- c[t]--;
- sumaTotal -= t;
- perdieron++;
- }
- c[a]++;
- printf("%d ", perdieron);
- }
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment