Maximize the expression

0

0 votes
Basic Programming, Bit Manipulation, Basics of Bit Manipulation, Bit manipulation, Observation
Problem

You are given three arrays A,B, and C. All three arrays consist of N integers.

You can perform the following operation on each index for at most one time:

  • Convert(i): Select a positive value D such that Ci & D=D and update Bi=BiD. Here,  and & denotes the bitwise XOR operation and bitwise AND operation.

You are required to maximize the following expression:

S=ni=1AiBi    

Input format

  • First line: A single integer N denoting the number of elements of the array
  • Next line: N integers of array A
  • Next line: N integers of array B
  • Next line: N integers of array C

Output format
Print a single integer that denotes the maximum value of S.

Constraints
1N105

1Ai,Bi,Ci<230

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For i=1, we can chose D=4
For i=2, we can chose D=4
For i=3, we can chose D=9

Editor Image

?