#include<bits/stdc++.h>
#define int unsigned long long
using namespace std;
const int N=4e5+2;
int n,a[N],s,c[N];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n>>s;
for (int i = 1; i <= n; i++)
{
cin>>a[i];
if(a[i]==s){
cout<<"YES"<<'\n';
system("pause");
return 0;
}
c[i]=c[i-1]+a[i];
}
//cout<<c[n]<<"\n";
int kn=s%c[n];
for (int i = 1; i <=n; i++)
{
a[i+n]=a[i];
c[i+n]=c[n]+c[i];
}
for (int i = 1; i <= n*2; i++)
{
int l=i+1,r=n*2;
while (l<r)
{
int mid=(l+r)>>1;
if((c[mid]-c[i])==kn){
cout<<"YES"<<'\n';
system("pause");
return 0;
}
else if((c[mid]-c[i])<kn) l=mid+1;
else r=mid-1;
}
if((c[l]-c[i])==kn){
cout<<"YES"<<'\n';
system("pause");
return 0;
}
}
cout<<"NO"<<'\n';
system("pause");
return 0;
}
my code为啥是WA 0pts