Page 1 of 1

11633 - Food portion sizes

Posted: Sat Sep 05, 2009 11:53 am
by Nahiyan Kamal
can anyone help me how to solve this problem? i have thought of a solution like this:

S=ax+by

let the food portion size if u

for first person,

i1=amount he needs
x1= amount wasted
y1=how many times he goes to fetch food

x1=u*ceil(i1/u)-i1
y1=ceil(i1/u)

s1=ax1+by1=(au+b)*ceil(i1/u)-a*i1
similarly
s2=(au+b)*ceil(i2/u)-a*i2
s3=(au+b)*ceil(i3/u)-a*i3
.......
S=S1+S2+.....
=(au+b)*(ceil(i1/u)+ceil(i2/u)+ceil(i3/u)+...)-a*(i1+i2+i3+.....)


now S is the ans

we can determine u to get S minimum.(y<=3) but u has to be very accurate so that it can be turned into fractoin (x/y form) brute force will make TLE.

am i correct?
so any idea how to solve this?

Re: 11633 - Food portion sizes

Posted: Tue Dec 23, 2014 9:07 am
by red_apricot
My model is the same as Nahiyan Kamal's. So, S-the-portion-size is any real number between max{w}/3 and max{w}. We are to find a "good" rational approximation to this optimal size. Nwo, we are not given any tolerance level as to which approximations are good enough. Maybe I'm missing something important from the problem statement, but I'm confused as to how to handle this problem, too.

Re: 11633 - Food portion sizes

Posted: Wed Dec 24, 2014 12:04 am
by brianfry713
You can solve it without using floating point. The result will always be an integer / 6.