连续子区间的和求优化QAQ

#include"bits/stdc++.h"
using namespace std;
long long n,m,a[100005],b[100005],ans;
int main(){
  scanf("%lld %lld",&n,&m);
  for(long long i=1;i<=n;++i) scanf("%lld",&a[i]),b[i]=b[i-1]+a[i];
  for(long long i=1;i<=n;++i) for(long long j=1;j<=i;++j) if(b[i]-b[j-1]==m) ++ans;
  printf("%lld",ans);
  return 0;
}