Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <strings.h>
- #include <math.h>
- #include <vector>
- #include <map>
- #include <utility>
- #include <ctype.h>
- using namespace std;
- vector <int> dp;
- int n , a , b , c ;
- int cut_ribbon(int rem )
- {
- if(rem == 0)
- {
- return 0;
- }
- if(rem<0)
- return -100000;
- if(dp[rem]!=-1)
- {
- return dp[rem];
- }
- int cut1 = cut_ribbon(rem-a);
- int cut2 = cut_ribbon(rem-b);
- int cut3 = cut_ribbon(rem-c);
- return dp[rem] = max(cut1, max (cut2 , cut3) )+1;
- }
- int main()
- {
- cin>>n>>a>>b>>c;
- dp = vector<int> (4001 , -1);
- cout<<cut_ribbon(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement