Needed help in the question 189A

Revision en1, by ClumsyBot, 2022-08-07 20:51:38

Can someone please tell me what am i doing wrong here?

#include<iostream>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<numeric>

using namespace std;

#define ll long long
#define mod 1e9+7
#define cy std::cout << "YES"<< std::endl
#define cn std::cout << "NO"<< std::endl
#define IN(x) cin >> x;
#define OUT(x) cout << x;

int solve(int x,int a,int b,int c){//it gives the maximum amount of ribbon when the length is x and we have to substract the length from a,b,c
  if (x < 0)
  {
    return INT_MIN;
  }
    int len1 = solve(x-a,a,b,c)+1;
    int len2 = solve(x-b,a,b,c)+1;
    int len3 = solve(x-c,a,b,c)+1;
  return max({len1,len2,len3});
}


int main()
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r", stdin);
      freopen("output.txt","w", stdout);
    #endif//
    int length,a,b,c;
    std::cin >> length>>a >>b >>c;
    cout << solve(length,a,b,c);

    return 0;
}
Tags dp

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English ClumsyBot 2022-08-07 20:51:38 1276 Initial revision (published)