https://www.codechef.com/LRNDSA02/problems/STFOOD

The problem is chef and street food. can any body explain why we take Si / Vi * Pi

You should at least share something like problem link or editorial link where you have problem.

Problem is very simple but I don’t know by Si,Vi and Pi is referring to.

I think you haven’t consider the input order which is Si,Pi and Vi.

profit by opening store for ith type of food will be =Pi/(Si+1)*Vi
final answer will be (maximum over all types)

How?

there are already Si stores chef opens another one hence total stores offering ith type of food is Si+1.
People interested from buying chef’s store are Pi/(Si+1)
and total profit will be (no. of people)*Vi

My solution link:
https://www.codechef.com/viewsolution/33185897

If you still has doubt Here is editorial link
https://discuss.codechef.com/t/stfood-editorial/51246

1 Like

https://www.codechef.com/viewsolution/33198949

i have used the same formula as in editorial .

As I have assumed you are taking inputs in wrong order

and you are also neglecting the order of arithmetic operators which is
/ > * > + > -

Here
Capture

it should be value*(people/(stores+1)) or value*people/(stores+1).

Take a look I have corrected it
https://www.codechef.com/viewsolution/33202519

1 Like