0pts求调
查看原帖
0pts求调
1042546
steamdream楼主2024/12/4 21:01
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,a[100010],ans;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	ll x=0;
	for(int i=n;i>=1;i--)
	{
		x+=a[i];
		if(x==m) 
		{
			ans++;
			x=0;
		}
	}
	if(x!=0) ans++;
	cout<<ans<<endl;
	return 0;
}

请dalao调调

2024/12/4 21:01
加载中...