#AT2491. G - OR Sum
G - OR Sum
当前没有测试数据。
G - OR Sum
Score : $600$ points
Problem Statement
There are length-$N$ sequences $A=(A_0,A_1,\ldots,A_{N-1})$ and $B=(B_0,B_1,\ldots,B_{N-1})$.
Takahashi may perform the following operation on $A$ any number of times (possibly zero):
- apply a left cyclic shift to the sequence $A$. In other words, replace $A$ with $A'$ defined by $A'_i=A_{(i+1)\% N}$, where $x\% N$ denotes the remainder when $x$ is divided by $N$.
Takahashi's objective is to maximize $\displaystyle\sum_{i=0}^{N-1} (A_i|B_i)$, where $x|y$ denotes the bitwise logical sum (bitwise OR) of $x$ and $y$.
Find the maximum possible $\displaystyle\sum_{i=0}^{N-1} (A_i|B_i)$.
What is the bitwise logical sum (bitwise OR)?
The logical sum (or the OR operation) is an operation on two one-bit integers ($0$ or $1$) defined by the table below.The bitwise logical sum (bitwise OR) is an operation of applying the logical sum bitwise.
$x$ </th> | $y$ </th> | $x|y$ </th> </tr> </thead> |
$0$ | $0$ | $0$ |
$0$ | $1$ | $1$ |
$1$ | $0$ | $1$ |
$1$ | $1$ | $1$ |