Great!  Thanks!

I think one possible problem is that   for f[c][m],   the range of m should
be    m= [0, min(c/2,  n/2)]

In your code, m is only related to n/2.


2013/5/12 Piyush Raman <piyush2011...@gmail.com>

> The test cases are not public. Gonna have to find the bug in the logic!
> Here's the link of the problem statement:
> http://www.spoj.com/problems/MPILOT/
>
>
> On Mon, May 13, 2013 at 1:36 AM, Tian Guo <tian....@epfl.ch> wrote:
>
>> Could you post the test case you failed? Then we can have a check.
>>
>>
>> 2013/5/12 Piyush Raman <piyush2011...@gmail.com>
>>
>>> I have been trying to solve this problem using DP. i managed to realize
>>> the problem in the form of recurrence..
>>> The solution is:
>>> Suppose the task was : given N pilots you have to assign N/2 of them as
>>> captains and N/2 as assistances. Furthermore you need to do this in a way
>>> such that for every 1<=X<=N, the group of the youngest X pilots doesn't
>>> contain more captains than assistances. And you want to do all this in the
>>> cheapest way possible (every pilot has an captain_salary[] and an
>>> assistant_salary[] value and the cost is computed as in the original
>>> problem).
>>>
>>> So let f(c,m) be the best we can do given that we already assigned the
>>> roles to the first c-1 pilots and currently there are m more assistances
>>> than there are captains.
>>>
>>> It is now true that (except for boundary cases) that f(c,m) = min
>>> (f(c+1,m-1)+captain_salary[c],f(c+1,m+1)+ assistant_salary[c]).
>>>
>>> Here's my code:
>>> http://ideone.com/M5b9da
>>>
>>> I'm  getting WA on 10th case again and again. Please help!
>>>
>>> Is there some other approach as well??
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>>
>>>
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Reply via email to