PROBLEM LINK: Contest Page | CodeChef
Author: Setter’s name
Tester: Tester’s name
Editorialist: Editorialist’s name
DIFFICULTY : EASY
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.
Iterate through all costs and check if any goodie costs exactly R/4.
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.
using namespace std;
if(r%4 != 0)