Skip to content

Instantly share code, notes, and snippets.

@joaogui1
Created March 20, 2016 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaogui1/d4e5e062690f0b3ca370 to your computer and use it in GitHub Desktop.
Save joaogui1/d4e5e062690f0b3ca370 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll vet[1000010], x, sm;
int t,n,j;
bool ok;
int main(){
scanf("%d", &t);
while(t--){
scanf("%d %lld", &n, &x);
ok = false;
j = 0;
sm = 0LL;
for(int i = 0; i < n; i++){
scanf("%lld", &vet[i]);
sm += vet[i];
while(sm >= x and j <= i){
if(sm == x)ok = true;
sm -= vet[j++];
}
}
if(ok)printf("YES\n");
else printf("NO\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment