class BadNeighbors {
public:
    int maxDonations(vector <int>);
};
int dp[51][2][2];
int l;
vector<int> v;
int solve(int id, int taken, int first) {
    if(id==l)
        return 0;
    int &d = dp[id][taken][first];
    if(~d) return d;
    d = 0;
    if(id!=l-1) {
        if(taken==0) {
            d >?= v[id] + solve(id+1, 1, (id==0) | first);
            d >?= solve(id+1, 0, first);
        }
        else {
            d >?= solve(id+1, 0, first);
        }
    }
    else {
        if(first==1) {
            d >?= solve(id+1, 1, first);
        }
        else {
            if(taken==0) {
            d >?= v[id] + solve(id+1, 1, first);
            d >?= solve(id+1, 0, first);
            }
            else {
            d >?= solve(id+1, 0, first);
            }
        }
    }
    return d;
}
int BadNeighbors::maxDonations(vector <int> v) {
    :: v = v;
    l = v.size();
    memset(dp, -1, sizeof dp);
    return solve(0, 0, 0);
}


On Wed, Dec 22, 2010 at 9:00 PM, mohit ranjan <shoonya.mo...@gmail.com>wrote:

> Ok, I got the recurrence relation at
>
> http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=tccc04_online_rd_4
>
>
> Mohit
>
>
>
> On Wed, Dec 22, 2010 at 8:33 PM, mohit ranjan <shoonya.mo...@gmail.com>wrote:
>
>> Hi All,
>>
>> Can anybody help me with some hint for
>> http://www.topcoder.com/stat?c=problem_statement&pm=2402&rd=5009
>>
>>
>> Mohit
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to