Lucian_Adrian

#860 Pachete1

Oct 12th, 2021
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n;
  6. cin >> n;
  7. int c;
  8. cin >> c;
  9. int tmp;
  10. int s=0;
  11. int cnt=1;
  12. while (n)
  13. {
  14. cin >> tmp;
  15. s+=tmp;
  16. if ( s > c)
  17. {
  18. cnt++;
  19. s=tmp;
  20. }
  21. n--;
  22. }
  23. cout << cnt;
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment