static double maxAvgSubArray ( int a [ ] , int n , int x , int y ) {
  int prefix [ ] = new int [ n ] ;
  prefix [ 0 ] = a [ 0 ] ;
  for ( int i = 1 ;
  i < n ;
  i ++ ) prefix [ i ] = prefix [ i - 1 ] + a [ i ] ;
  double maximum = 0 ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    for ( int j = i + x - 1 ;
    j < i + y && j < n ;
    j ++ ) {
      double sum = prefix [ j ] ;
      if ( i > 0 ) sum -= prefix [ i - 1 ] ;
      double current = sum / ( double ) ( j - i + 1 ) ;
      maximum = Math . max ( maximum , current ) ;
    }
  }
  return maximum ;
}

static double maxAvgSubArray ( int a [ ] , int n , int x , int y ) { int prefix [ ] = new int [ n ] ; prefix [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) prefix [ i ] = prefix [ i - 1 ] + a [ i ] ; double maximum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + x - 1 ; j < i + y && j < n ; j ++ ) { double sum = prefix [ j ] ; if ( i > 0 ) sum -= prefix [ i - 1 ] ; double current = sum / ( double ) ( j - i + 1 ) ; maximum = Math . max ( maximum , current ) ; } } return maximum ; }
(method_declaration (modifiers) type: (floating_point_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (array_access array: (identifier) index: (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: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (identifier)))))) (local_variable_declaration type: (floating_point_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 (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))) condition: (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) right: (binary_expression left: (identifier) right: (identifier))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (cast_expression type: (floating_point_type) value: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))))) (return_statement (identifier))))