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

25657번 - Add One 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB61141429.787%

문제

Given $n$ integers $a_1, a_2, \ldots, a_n,ドル you want to perform the following operation exactly $n-1$ times.

  • Choose two integers $x$ and $y$ in the sequence, remove them, and add a number with the value $x\oplus y$.

Since this alone is just too boring, you can additionally choose a number and add one to it at any moment. You must perform the add-one operation exactly once.

Eventually, only one number will be left in this sequence, and you need to maximize this remaining number. Print the maximum value of the remaining number.

입력

The first line of the input contains a single integer $n$ (1ドル \le n \le 10^6$).

The next line of the input contains $n$ integers $a_1, a_2, \ldots, a_n$ (0ドル \le a_i < 2^{60}$).

출력

Output a single line containing a single integer: the maximum value of the remaining number.

제한

예제 입력 1

4
1 2 1 2

예제 출력 1

7

예제 입력 2

5
1 2 3 4 5

예제 출력 2

14

예제 입력 3

6
1 2 4 7 15 31

예제 출력 3

47

힌트

In the first example, the optimal strategy is:

  • Choose 1ドル$ and 2ドル$: $[\mathbf{1}, \mathbf{2}, 1, 2] \to [1, 2, \mathbf{3}]$
  • Choose 1ドル$ and 2ドル$: $[\mathbf{1}, \mathbf{2}, 3] \to [3, \mathbf{3}]$
  • Add one to the number 3ドル$: $[\mathbf{3}, 3] \to [3, \mathbf{4}]$
  • Choose 3ドル$ and 4ドル$: $[\mathbf{3}, \mathbf{4}] \to [\mathbf{7}]$

출처

Camp > Petrozavodsk Programming Camp > Summer 2022 > Day 3: Qingyu, flower and their friends’ Contest A번

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

출처

대학교 대회

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

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