Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- int main()
- {
- int grupi,maksimum;
- int gondoli=1,zbir=0;
- cin>>grupi>>maksimum;
- int luge[grupi];
- for(int i=0;i<grupi;i++){
- cin>>luge[i];
- }
- for(int i=0;i<grupi;i++){
- if(zbir+luge[i]<=maksimum){
- zbir+=luge[i];
- }
- else {
- zbir=luge[i];
- gondoli+=1;
- }
- }
- cout<<gondoli<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement