Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. // 7 15 8 6 4 2 5 3 3
  6.  
  7. int total_truc=0;
  8. int total_weight=0;
  9. while(true)
  10. {
  11. int integer,weight;
  12. cin>>integer>>weight;
  13. if(integer==0 && weight==0)
  14. {
  15. break;
  16. }
  17. int number;
  18. int i;
  19. for(i=0;i<integer;i++)
  20. {
  21. cin>>number;
  22. total_weight=total_weight+number;
  23. if(total_weight>weight)
  24. {
  25. total_truc++;
  26. total_weight=number;
  27. }
  28.  
  29. }
  30. cout<<total_truc+1<<endl;
  31. total_truc==0;
  32. total_weight==0;
  33. }
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement