Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- // 7 15 8 6 4 2 5 3 3
- int total_truc=0;
- int total_weight=0;
- while(true)
- {
- int integer,weight;
- cin>>integer>>weight;
- if(integer==0 && weight==0)
- {
- break;
- }
- int number;
- int i;
- for(i=0;i<integer;i++)
- {
- cin>>number;
- total_weight=total_weight+number;
- if(total_weight>weight)
- {
- total_truc++;
- total_weight=number;
- }
- }
- cout<<total_truc+1<<endl;
- total_truc==0;
- total_weight==0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement