Approach

Revision en3, by codeforces2k19, 2019-05-25 10:38:03

I came across the solution to the problem:

http://codeforces.com/problemset/problem/189/A

can anyone explain me what is the approach to get this recursive relation(I am a beginner):

ll fun(ll n)

{

if(n<0)


    return INT_MIN;


if(n==0)


    return 0;


if(dp[n]!=-1)


    return dp[n];


dp[n]=max(fun(n-a)+1,max(fun(n-b)+1,fun(n-c)+1));


return dp[n];

}

Tags #dp, #beginner, approach

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English codeforces2k19 2019-05-25 10:38:03 40
en2 English codeforces2k19 2019-05-25 10:37:15 8
en1 English codeforces2k19 2019-05-25 10:35:40 398 Initial revision (published)