Created
March 20, 2016 20:37
-
-
Save joaogui1/d4e5e062690f0b3ca370 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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