代码:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m;
int a[N];
int ans = 1;
int main()
{cin >> n >> m;for (int i = 1; i <= n; i++)cin >> a[i];int num = 0;for (int i = 1; i <= n; i++){if (num + a[i] <= m){num += a[i];}else{ans++;num=a[i];}}
cout<<ans;return 0;
}