# PROBLEM LINK: Contest Page | CodeChef

Author: Setter’s name

Tester: Tester’s name

Editorialist: Editorialist’s name

DIFFICULTY : EASY

Nill

# PROBLEM:

You got R laddus. There are N types of goodies available and the ith goodie costs Ci Laddus. Since you are a team of 4, you want a goodie each for each member of the team. (i.e. every member should get 1 goodie). Also, you want to spend all of your Laddus. But you don’t want any disputes. So you have to give the same type of goodie of all. You want to determine whether you will be able to buy goodies such that all the above-given conditions are met.

# QUICK EXPLANATION:

Iterate through all costs and check if any goodie costs exactly R/4.

# EXPLANATION:

Let’s simplify the question. You should give the same type of goodie to all 4 team membrs, and spend all the money. This is possible only if one of the goodies costs exactly ¼th of the total laddus. So we just need to iterate through all costs and check if any goodie costs exactly R/4.

# SOLUTIONS:

Setter's Solution

using namespace std;

void solve(){

int n,r;

cin>>n>>r;

vector s(n);

for(int i=0;i<n;i++)

{

cin>>s[i];

}

if(r%4 != 0)

{

cout<<“No\n”;

return;

}

if(find(s.begin(),s.end(),r/4)!=s.end())

cout<<“Yes”;

else

{

cout<<“No”;

}

cout<<"\n";

}

int main(){

ios_base::sync_with_stdio(false);

cin.tie(NULL);

int t;

cin>>t;

while(t–)

{

solve();

}

return 0;

}

Tester's Solution

Same Person

Editorialist's Solution

Same Person