3 0 1 3 0 2 3
8
If Takahashi does not perform the operation, $A$ remains $(0,1,3)$, and we have $\displaystyle\sum_{i=0}^{N-1} (A_i|B_i)=(0|0)+(1|2)+(3|3)=0+3+3=6$;
if he performs the operation once, making $A=(1,3,0)$, we have $\displaystyle\sum_{i=0}^{N-1} (A_i|B_i)=(1|0)+(3|2)+(0|3)=1+3+3=7$; and
if he performs the operation twice, making $A=(3,0,1)$, we have $\displaystyle\sum_{i=0}^{N-1} (A_i|B_i)=(3|0)+(0|2)+(1|3)=3+2+3=8$.
If he performs the operation three or more times, $A$ becomes one of the sequences above, so the maximum possible $\displaystyle\sum_{i=0}^{N-1} (A_i|B_i)$ is $8$, which should be printed.5 1 6 1 4 3 0 6 4 0 1
23
The value is maximized if he performs the operation three times, making $A=(4,3,1,6,1)$,
where $\displaystyle\sum_{i=0}^{N-1} (A_i|B_i)=(4|0)+(3|6)+(1|4)+(6|0)+(1|1)=4+7+5+6+1=23$.{
"problem": {
"name": "OR Sum",
"description": {
"content": "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 l",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 8000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc291_g"
},
"statements": [
{
"statement_type": "Markdown",
"content": "There are length-$N$ sequences $A=(A_0,A_1,\\ldots,A_{N-1})$ and $B=(B_0,B_1,\\ldots,B_{N-1})$. \nTakahashi may perform the following operation on $A$ any number of times (possibly zero):\n\n* apply a l...",
"is_translate": false,
"language": "English"
}
]
}