title: Minimum Time Write Characters Using Insert Delete Copy Operation
signature: minimum_time_write_characters_using_insert_delete_copy_operation <- function(n, insrt, remov, cpy) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(n, insrt, remov, cpy, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n, insrt, remov, cpy), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          59L, 75L, 12L, 45L, 
          351L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          66L, 68L, 32L, 41L, 
          382L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          98L, 55L, 69L, 5L, 
          195L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          63L, 4L, 41L, 12L, 
          76L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          99L, 37L, 98L, 55L, 
          460L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          45L, 28L, 59L, 7L, 
          147L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          60L, 53L, 40L, 52L, 
          405L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          11L, 96L, 50L, 50L, 
          392L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          96L, 95L, 48L, 84L, 
          694L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          54L, 6L, 50L, 82L, 
          244L
      )))
  
  }
  
  main()
source_py: def minimum_time_write_characters_using_insert_delete_copy_operation(N, insrt, remov, cpy):
      if (N == 0):
          return 0
      if (N == 1):
          return insrt
      dp = ([0] * (N + 1))
      for i in range(1, (N + 1)):
          if ((i % 2) == 0):
              dp[i] = min((dp[(i - 1)] + insrt), (dp[(i // 2)] + cpy))
          else:
              dp[i] = min((dp[(i - 1)] + insrt), ((dp[((i + 1) // 2)] + cpy) + remov))
      return dp[N]
source_cpp: int minimum_time_write_characters_using_insert_delete_copy_operation(int N, int insert, int remove, int copy) {
    if ( N == 0 ) return 0;
    if ( N == 1 ) return insert;
    int dp [ N + 1 ];
    memset ( dp, 0, sizeof ( dp ) );
    for ( int i = 1;
    i <= N;
    i ++ ) {
      if ( i % 2 == 0 ) dp [ i ] = min ( dp [ i - 1 ] + insert, dp [ i / 2 ] + copy );
      else dp [ i ] = min ( dp [ i - 1 ] + insert, dp [ ( i + 1 ) / 2 ] + copy + remove );
    }
    return dp [ N ];
  }