Skip to content

Instantly share code, notes, and snippets.

@Zyro9922
Created March 2, 2018 15:07
Show Gist options
  • Save Zyro9922/e20e496563d99dc981aac9079caa275b to your computer and use it in GitHub Desktop.
Save Zyro9922/e20e496563d99dc981aac9079caa275b to your computer and use it in GitHub Desktop.
//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--;
}
}
@Zyro9922
Copy link
Author

Zyro9922 commented Mar 2, 2018

screen shot 2018-03-02 at 8 44 33 pm
QUESTION

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment