Logo
(追記) (追記ここまで)

21122번 - Bank Security Unification 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB68262549.020%

문제

The Bytelandian government has issued the Bank Security Unification law (or, shortly, the BSU law). The recent law regulates the usage of Wi-Fi routers in banks and other financial institutions.

According to the BSU law, all the $n$ Wi-Fi routers in a bank must be located in a straight line. Suppose that the $i$-th router operates at the frequency $f_i$. Denote the security of a connection between two adjacent routers as $f_{i},円,円 \&,円,円 f_{i+1},ドル where $\&$ is the bitwise AND operation.

A set of at least two routers numbered 1ドル \le i_1 < i_2 < \dots < i_k \le n$ must be chosen as active. All other routers will be kept inactive so that they can replace the active ones if any of them would break. Denote the security of the network as the sum of the securities of all connections between adjacent active routers. In other words, the security of the network is calculated as $\sum\limits_{j=1}^{k-1} f_{i_j},円,円\&,円,円f_{i_{j+1}}$.

You are an employee of a large Bytelandian bank. Surely, the bank is obliged to comply with the BSU law. The routers are already placed in a line, and their placement cannot be changed. Now you want to choose some of the routers as active to maximize the security of the network.

입력

The first line contains an integer $n,ドル denoting the number of Wi-Fi routers in the bank (2ドル \le n \le 10^6$).

The second line contains $n$ integers $f_1, f_2, \ldots, f_n,ドル where $f_i$ is the frequency of the $i$-th router in the line (0ドル \le f_i \le 10^{12}$).

출력

Print the maximum possible security of the network.

제한

예제 입력 1

5
1 2 3 1 3

예제 출력 1

5

예제 입력 2

4
1 2 4 0

예제 출력 2

0

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 8: Belarusian SU Contest, Yandex Cup, Grand Prix of Belarud D번

Contest > Open Cup > 2020/2021 Season > Stage 12: Grand Prix of Belarus D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /