其他分享
首页 > 其他分享> > CCF CSP 201703

CCF CSP 201703

作者:互联网

1

#include<bits/stdc++.h>
using namespace std;
int n,arr[1010],k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	int ans=0,now=0,i=1;
	while(i<=n){
		if(now+arr[i]>=k){
			ans++,now=0;
		}
		else{
			now+=arr[i];
		}
		i++;
	}
	if(now!=0){
		ans++;
	}
	cout<<ans<<endl; 
}

标签:arr,now,int,201703,cin,++,ans,CCF,CSP
来源: https://blog.csdn.net/weixin_43975891/article/details/113823569