i have solved above problem using frequency array but i read in comments other approaches using set,map,greedy.
What are different solution to this problem?

Search your query through google. There are many different approach already discussed in codechef discussion or you will find many other blogs with good explanation. Just type EGYPIZZA - Pizza

all of them wants his amount of pizza in one slice see this line, it means each friend must be given pizza as only a slice ie if someone wants 1/2 pizza, he should be given 1/2 piece as a whole rather than 2 “1/4” pieces.

So algo works something like this

  1. Divide pizza among people wanting 3/4 pizza with 1/4 pizza

  2. Divide pizza among people wanting 1/2 pizza with 1/2 pizza

  3. Divide pizza among people wanting 1/2 pizza with 2 person that wants 1/4 pizza

  4. Divide pizza among 4 people if all wants 1/4 pizza

  5. 1 pizza for abotrika

1 Like

I am using the approach described above but my code still gives wrong answer!
Can anyone help what’s wrong with my code?

I already googled it but was not able to find any solution other than frequency array.

I know this approach , i am looking for approach other than this

1 Like