public static void process ( ) throws IOException {
  int n = ni ( ) ;
  int k = ni ( ) ;
  int a [ ] = new int [ n + 1 ] ;
  int beh [ ] = new int [ n + 1 ] ;
  int p [ ] = new int [ n + 1 ] ;
  int sum = 0 ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    a [ i + 1 ] = ni ( ) ;
  }
  for ( int i = 1 ;
  i <= n ;
  i ++ ) {
    beh [ i ] = ni ( ) ;
  }
  if ( k >= n ) {
    for ( int i = 0 ;
    i < n ;
    i ++ ) {
      sum += a [ i + 1 ] ;
    }
    pn ( sum ) ;
  }
  else {
    for ( int i = 1 ;
    i <= n ;
    i ++ ) {
      if ( beh [ i ] == 1 ) {
        sum += a [ i ] ;
        p [ i ] = p [ i - 1 ] ;
      }
      else {
        p [ i ] = p [ i - 1 ] + a [ i ] ;
      }
    }
    int max = Integer . MIN_VALUE ;
    for ( int i = 1 ;
    i <= ( n - k + 1 ) ;
    i ++ ) {
      int x = p [ i + ( k - 1 ) ] - p [ i - 1 ] ;
      max = Math . max ( max , x ) ;
    }
    sum += max ;
    pn ( sum ) ;
  }
}

public static void process ( ) throws IOException { int n = ni ( ) ; int k = ni ( ) ; int a [ ] = new int [ n + 1 ] ; int beh [ ] = new int [ n + 1 ] ; int p [ ] = new int [ n + 1 ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i + 1 ] = ni ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { beh [ i ] = ni ( ) ; } if ( k >= n ) { for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i + 1 ] ; } pn ( sum ) ; } else { for ( int i = 1 ; i <= n ; i ++ ) { if ( beh [ i ] == 1 ) { sum += a [ i ] ; p [ i ] = p [ i - 1 ] ; } else { p [ i ] = p [ i - 1 ] + a [ i ] ; } } int max = Integer . MIN_VALUE ; for ( int i = 1 ; i <= ( n - k + 1 ) ; i ++ ) { int x = p [ i + ( k - 1 ) ] - p [ i - 1 ] ; max = Math . max ( max , x ) ; } sum += max ; pn ( sum ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) (throws (type_identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (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 (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (method_invocation name: (identifier) arguments: (argument_list)))))) (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 (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation name: (identifier) arguments: (argument_list)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (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 (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier))))) alternative: (block (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: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) alternative: (block (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: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (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: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier))))))))