static Vector < Integer > solve ( int X , Vector < Integer > A ) {
  int min = Integer . MAX_VALUE ;
  int ind = - 1 ;
  for ( int i = 0 ;
  i < A . size ( ) ;
  i ++ ) {
    if ( A . get ( i ) < min ) {
      min = A . get ( i ) ;
      ind = i ;
    }
  }
  int maxIndChosen = X / min ;
  Vector < Integer > ans = new Vector < > ( ) ;
  if ( maxIndChosen == 0 ) {
    return ans ;
  }
  for ( int i = 0 ;
  i < maxIndChosen ;
  i ++ ) {
    ans . add ( ind ) ;
  }
  int temp = maxIndChosen ;
  int sum = maxIndChosen * A . get ( ind ) ;
  for ( int i = 0 ;
  i < ind ;
  i ++ ) {
    if ( sum - X == 0 || temp == 0 ) break ;
    while ( ( sum - A . get ( ind ) + A . get ( i ) ) <= X && temp != 0 ) {
      ans . remove ( 0 ) ;
      ans . add ( i ) ;
      temp -- ;
      sum += ( A . get ( i ) - A . get ( ind ) ) ;
    }
  }
  Collections . sort ( ans ) ;
  return ans ;
}

static Vector < Integer > solve ( int X , Vector < Integer > A ) { int min = Integer . MAX_VALUE ; int ind = - 1 ; for ( int i = 0 ; i < A . size ( ) ; i ++ ) { if ( A . get ( i ) < min ) { min = A . get ( i ) ; ind = i ; } } int maxIndChosen = X / min ; Vector < Integer > ans = new Vector < > ( ) ; if ( maxIndChosen == 0 ) { return ans ; } for ( int i = 0 ; i < maxIndChosen ; i ++ ) { ans . add ( ind ) ; } int temp = maxIndChosen ; int sum = maxIndChosen * A . get ( ind ) ; for ( int i = 0 ; i < ind ; i ++ ) { if ( sum - X == 0 || temp == 0 ) break ; while ( ( sum - A . get ( ind ) + A . get ( i ) ) <= X && temp != 0 ) { ans . remove ( 0 ) ; ans . add ( i ) ; temp -- ; sum += ( A . get ( i ) - A . get ( ind ) ) ; } } Collections . sort ( ans ) ; return ans ; }
(method_declaration (modifiers) type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) 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: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (identifier)))) (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 (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (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: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (break_statement)) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) right: (identifier)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (return_statement (identifier))))