title: Maximum Number Segments Lengths B C
signature: func maximumNumberSegmentsLengthsBC(n int, a int, b int, c int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(n int, a int, b int, c int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n, a, b, c),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(23, 
  	16, 
  	23, 
  	18, 1)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(62, 
  	76, 
  	81, 
  	97, -1)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(32, 
  	46, 
  	1, 
  	78, 32)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(82, 
  	48, 
  	72, 
  	58, -1)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(94, 
  	99, 
  	62, 
  	38, -1)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(44, 
  	21, 
  	46, 
  	60, -1)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(4, 
  	57, 
  	2, 
  	77, 2)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(53, 
  	23, 
  	80, 
  	5, 7)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(9, 
  	55, 
  	26, 
  	85, -1)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(23, 
  	15, 
  	73, 
  	42, -1)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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 ];
  }