Created
March 2, 2018 15:07
-
-
Save Zyro9922/e20e496563d99dc981aac9079caa275b 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
//ALI | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int trial=0,n,x; // trial -> no. of trial n -> no. of TA's x -> amount of money | |
cin>>trial; | |
while(trial>0) | |
{ | |
cin>>n>>x; // taking in n & x | |
int arr[n]; | |
int sum=0; | |
for(int i = 0 ; i < n ; i++) // making array. getting the "n" values | |
cin>>arr[i]; | |
//array succesful | |
for(int j = 0 ; j < n ; j++) | |
{ | |
sum = 0; | |
for(int i = j ; i < n ; i++) | |
{ | |
sum = sum + arr[i]; | |
if(sum == x) | |
break; | |
else if (sum > x) | |
break; | |
} | |
if(sum==x) | |
break; | |
} | |
if(sum == x) | |
cout<<"YES"; | |
else | |
cout<<"NO"; | |
trial--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
QUESTION