A bus stop queue has n groups of people. The i-th group from the beginning has ai people. Every 30 minutes an empty bus arrives at the bus stop, it can carry at most m people. Naturally, the people from the first group enter the bus first.
Answers
Answered by
4
Answer:
#include<iostream>
using namespace std;
void queue(int,int,int*);
int main()
{
int n,m;
t2:cin>>n>>m;
if(n<1 || m>100)
goto t2;
int a[n];
for(int i=0;i<n;i++)
{
t:cin>>a[i];
if(a[i]>=1 && a[i]<=m)
continue;
else
goto t;
}
queue(n,m,a);
}
void queue(int n,int m,int *a)
{
int c,r=0;
for(int i=0;i<n;i++)
{
r+=a[i];
}
c=(r/m)+1;
cout<<c;
}
Similar questions