Advertisement
Guest User

DP

a guest
Feb 2nd, 2017
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. for (int i = 1; i <= n; i++)
  2.     dp[i] = -inf;
  3.  
  4. dp[0] = 0;
  5.  
  6. for (int i = min(a, b, c); i <= n; i++)
  7. {
  8.   if (i >= a) dp[i] = max( dp[i], dp[i - a] + 1 );
  9.   if (i >= b) dp[i] = max( dp[i], dp[i - b] + 1 );
  10.   if (i >= c) dp[i] = max( dp[i], dp[i - c] + 1 );
  11. }
  12. ответ -> dp[n];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement