| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 5 | 2 | 2 | 40.000% |
As a modern alchemy student, you are taking an exam in Alchembit, a hybrid between alchemy and modern technology. In the exam, you are given $N$ potions (numbered from $1$ to $N$) where potion $i$ has a potency of an integer $A_i$. You start the exam with a score of $0$.
You can increase your score by doing the following procedure.
For example, if you have $5$ potions with potencies $A = [19, 12, 10, 20, 23]$, and you choose interval $[2, 3]$, then your score will be increased by $12 \,\&\, 10 = 8$. Then, potions $2$ and $3$ are fused into a new potion with a potency of $12 \,\&\, 10 = 8$. After the renumbering procedure (step 4), A becomes $[19, 8, 20, 23]$.
You can perform the above procedure until there is only one potion left. Determine the maximum score that you can achieve.
The first line consists of an integer $N$ ($2 ≤ N ≤ 100\, 000$).
The second line consists of $N$ integers $A_i$ ($0 ≤ A_i < 2^{30}$).
Output a single integer representing the maximum score that you can get.
5 19 12 10 20 23
28
First, choose the interval $[2, 3]$ so that your score is increased by $12 \,\&\, 10 = 8$, and $A$ becomes $[19, 8, 20, 23]$. Next, choose the interval $[3, 4]$ so that your score is increased by $20 \,\&\, 23 = 20$, and $A$ becomes $[19, 8, 20]$. Finally, choose the interval $[1, 3]$ so that your score is increased by $19 \,\&\, 8 \,\&\, 20 = 0$, and $A$ becomes $[0]$.
4 1000000000 1000000000 1000000000 1000000000
3000000000
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2024 H번