Advertisement
Josif_tepe

Untitled

Sep 26th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4. int main()
  5. {
  6.   int grupi,maksimum;
  7.   int gondoli=1,zbir=0;
  8.   cin>>grupi>>maksimum;
  9.   int luge[grupi];
  10.   for(int i=0;i<grupi;i++){
  11.     cin>>luge[i];
  12.   }
  13.   for(int i=0;i<grupi;i++){
  14.     if(zbir+luge[i]<=maksimum){
  15.         zbir+=luge[i];
  16.     }
  17.     else {
  18.             zbir=luge[i];
  19.         gondoli+=1;
  20.     }
  21.   }
  22.   cout<<gondoli<<endl;
  23.  
  24.  
  25.  return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement