#include<bits/stdc++.h>
using namespace std;
class Solution{
public:
int solve(vector < int > num,int m)
{
int ans=1,sum=0;
for(int i=0; i<num.size(); i++)
{
if(sum+num[i]>m)
{
ans++;
sum=num[i];
}
else sum+=num[i];
}
return ans;
}
};
int main()
{
Solution x;
int n,m;vector < int > num;
cin>>n>>m;
for(int i=1,x; i<=n; i++)
{
cin>>x;
num.push_back(x);
}
cout<<x.solve(num,m)<<endl;
return 0;
}
标签:10006,1.1,int,sum,num,ans,数列
From: https://www.cnblogs.com/dadidididi/p/16599904.html