title: Maximum Number Segments Lengths B C
signature: int maximumNumberSegmentsLengthsBC(int n, int a, int b, int c) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual == expected;
  }
  
  string driver(int n, int a, int b, int c, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n, a, b, c), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver(23, 16, 23, 18, 1); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver(62, 76, 81, 97, -1); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver(32, 46, 1, 78, 32); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver(82, 48, 72, 58, -1); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver(94, 99, 62, 38, -1); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver(44, 21, 46, 60, -1); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver(4, 57, 2, 77, 2); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver(53, 23, 80, 5, 7); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver(9, 55, 26, 85, -1); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver(23, 15, 73, 42, -1); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
source_py: def maximum_number_segments_lengths_b_c(n, a, b, c):
      dp = ([(- 1)] * (n + 10))
      dp[0] = 0
      for i in range(0, n):
          if (dp[i] != (- 1)):
              if ((i + a) <= n):
                  dp[(i + a)] = max((dp[i] + 1), dp[(i + a)])
              if ((i + b) <= n):
                  dp[(i + b)] = max((dp[i] + 1), dp[(i + b)])
              if ((i + c) <= n):
                  dp[(i + c)] = max((dp[i] + 1), dp[(i + c)])
      return dp[n]
source_cpp: int maximum_number_segments_lengths_b_c(int n, int a, int b, int c) {
    int dp [ n + 1 ];
    memset ( dp, - 1, sizeof ( dp ) );
    dp [ 0 ] = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( dp [ i ] != - 1 ) {
        if ( i + a <= n ) dp [ i + a ] = max ( dp [ i ] + 1, dp [ i + a ] );
        if ( i + b <= n ) dp [ i + b ] = max ( dp [ i ] + 1, dp [ i + b ] );
        if ( i + c <= n ) dp [ i + c ] = max ( dp [ i ] + 1, dp [ i + c ] );
      }
    }
    return dp [ n ];
  }