题目链接:Codeforces 435A Queue on Bus Stop
#include <iostream>
using namespace std;
const int MAX_N = 100 + 10;
int arr[MAX_N];
int main()
{
int n, m, cnt = 0, temp = 0;
cin >> n >> m;
for(int i = 0; i < n; i++)
cin >> arr[i];
for(int i = 0; i < n; i++)
{
if(arr[i] == m)
cnt++;
else
{
temp = arr[i];
i++;
for(; i < n; i++)
{
if(temp + arr[i] > m)
{
cnt++;
i--;
temp = 0;
break;
}
else
{
temp += arr[i];
}
}
}
}
if(temp)
cnt++;
cout << cnt << endl;
return 0;
}