static int dfs ( int d , int g , Problem [ ] array , String select , int ans ) {
  if ( select . length ( ) == d ) {
    int total = 0 ;
    int cnt = 0 ;
    for ( int i = 0 ;
    i < d ;
    i ++ ) {
      if ( select . charAt ( i ) == '1' ) {
        total += array [ i ] . total ;
        cnt += array [ i ] . p ;
      }
    }
    if ( g <= total ) {
      return cnt ;
    }
    for ( int i = d - 1 ;
    i >= 0 ;
    i -- ) {
      if ( select . charAt ( i ) == '0' ) {
        double zanScore = g - total ;
        int zanCnt = ( int ) Math . ceil ( zanScore / ( 100 * ( i + 1 ) ) ) ;
        if ( zanCnt < array [ i ] . p ) {
          cnt += zanCnt ;
        }
        else {
          cnt = Integer . MAX_VALUE ;
        }
        break ;
      }
    }
    return cnt ;
  }
  ans = Math . min ( ans , dfs ( d , g , array , select + "0" , ans ) ) ;
  ans = Math . min ( ans , dfs ( d , g , array , select + "1" , ans ) ) ;
  return ans ;
}

static int dfs ( int d , int g , Problem [ ] array , String select , int ans ) { if ( select . length ( ) == d ) { int total = 0 ; int cnt = 0 ; for ( int i = 0 ; i < d ; i ++ ) { if ( select . charAt ( i ) == '1' ) { total += array [ i ] . total ; cnt += array [ i ] . p ; } } if ( g <= total ) { return cnt ; } for ( int i = d - 1 ; i >= 0 ; i -- ) { if ( select . charAt ( i ) == '0' ) { double zanScore = g - total ; int zanCnt = ( int ) Math . ceil ( zanScore / ( 100 * ( i + 1 ) ) ) ; if ( zanCnt < array [ i ] . p ) { cnt += zanCnt ; } else { cnt = Integer . MAX_VALUE ; } break ; } } return cnt ; } ans = Math . min ( ans , dfs ( d , g , array , select + "0" , ans ) ) ; ans = Math . min ( ans , dfs ( d , g , array , select + "1" , ans ) ) ; return ans ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (identifier))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (return_statement (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (block (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier)))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))))) (break_statement))))) (return_statement (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (binary_expression left: (identifier) right: (string_literal)) (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (binary_expression left: (identifier) right: (string_literal)) (identifier))))))) (return_statement (identifier))))