GastonFontenla

c2

Jun 19th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int c[101];
  6.  
  7. int main()
  8. {
  9.     int n, m, a;
  10.     scanf("%d %d", &n, &m);
  11.  
  12.     int sumaTotal = 0;
  13.     int perdieron = 0;
  14.     for(int i=0; i<n; i++)
  15.     {
  16.         scanf("%d", &a);
  17.         sumaTotal += a;
  18.         int t = 100;
  19.         while(sumaTotal > m)
  20.         {
  21.             while(c[t] == 0)
  22.                 t--;
  23.             c[t]--;
  24.             sumaTotal -= t;
  25.             perdieron++;
  26.         }
  27.         c[a]++;
  28.         printf("%d ", perdieron);
  29.     }
  30.     printf("\n");
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment