title: Maximum Number Segments Lengths B C
signature: function maximumNumberSegmentsLengthsBC(n: number, a: number, b: number, c: number): number {
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 ];
  }
question_info.test_list: [{"idx": 0, "outputs": 1, "inputs": {"n": 23, "a": 16, "b": 23, "c": 18}}, {"idx": 1, "outputs": -1, "inputs": {"n": 62, "a": 76, "b": 81, "c": 97}}, {"idx": 2, "outputs": 32, "inputs": {"n": 32, "a": 46, "b": 1, "c": 78}}, {"idx": 3, "outputs": -1, "inputs": {"n": 82, "a": 48, "b": 72, "c": 58}}, {"idx": 4, "outputs": -1, "inputs": {"n": 94, "a": 99, "b": 62, "c": 38}}, {"idx": 5, "outputs": -1, "inputs": {"n": 44, "a": 21, "b": 46, "c": 60}}, {"idx": 6, "outputs": 2, "inputs": {"n": 4, "a": 57, "b": 2, "c": 77}}, {"idx": 7, "outputs": 7, "inputs": {"n": 53, "a": 23, "b": 80, "c": 5}}, {"idx": 8, "outputs": -1, "inputs": {"n": 9, "a": 55, "b": 26, "c": 85}}, {"idx": 9, "outputs": -1, "inputs": {"n": 23, "a": 15, "b": 73, "c": 42}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(n: number, a: number, b: number, c: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n, a, b, c),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(23, 16, 23, 18, 1);
    console.log(`TEST-0...${result}`);
  
    result = driver(62, 76, 81, 97, -1);
    console.log(`TEST-1...${result}`);
  
    result = driver(32, 46, 1, 78, 32);
    console.log(`TEST-2...${result}`);
  
    result = driver(82, 48, 72, 58, -1);
    console.log(`TEST-3...${result}`);
  
    result = driver(94, 99, 62, 38, -1);
    console.log(`TEST-4...${result}`);
  
    result = driver(44, 21, 46, 60, -1);
    console.log(`TEST-5...${result}`);
  
    result = driver(4, 57, 2, 77, 2);
    console.log(`TEST-6...${result}`);
  
    result = driver(53, 23, 80, 5, 7);
    console.log(`TEST-7...${result}`);
  
    result = driver(9, 55, 26, 85, -1);
    console.log(`TEST-8...${result}`);
  
    result = driver(23, 15, 73, 42, -1);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: maximumNumberSegmentsLengthsBC
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js