洛谷P1181 数列分段Section I
时间:2019-10-20 17:09:27
收藏:0
阅读:50
https://www.luogu.org/problem/P1181
#include<bits/stdc++.h> using namespace std; int n,m,ans=1; int main(){ scanf ("%d%d",&n,&m); int k=0; while (n--){ int a; scanf ("%d",&a); if (k+a<=m){ k+=a; } else{ ans++; k=a; } } printf ("%d\n",ans);//做完之后输出,结束 }
原文:https://www.cnblogs.com/QingyuYYYYY/p/11707901.html
评论(0)