D - Array's Value


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

The symbol \oplus represents the bitwise XOR operator for integers. For example: 93=10012112=10102=109 \oplus 3 = 1001_2 \oplus 11_2 = 1010_2 = 10

The \textit{value} of an array such as a1,a2,,ana_1, a_2, \dots, a_n is defined as: a1a2ana_1 \oplus a_2 \oplus \dots \oplus a_n

You are given two arrays of numbers, a1,a2,,ana_1, a_2, \dots, a_n and b1,b2,,bnb_1, b_2, \dots, b_n.

For each ii from 11 to nn, you can swap the values of aia_i and bib_i. Write a program to perform these swaps in such a way that the sum of the values of both arrays is maximized.

ورودی🔗

The first line of input contains a positive integer nn, representing the length of the arrays.

1n1051 \leq n \leq 10^5

The second and third lines each contain nn positive integers separated by space, with the second line representing the elements of array aa and the third line representing the elements of array bb.

0ai,bi10180 \leq a_i, b_i \leq 10^{18}

خروجی🔗

Print a single integer, the maximum possible value for the sum of the values of both arrays.

مثال‌ها🔗

ورودی نمونه ۱🔗

3
1 2 3
3 1 2
Plain text

خروجی نمونه ۱🔗

6
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.