Mavis at School
Time limit3sMemory limit1024 MB
Given an array, find the segment whose maximum times its XOR sum is largest, and print that product.
- Level
Hard8 of 10
- Topics
- Divide and conquer, Stack, Prefix sum, Trie
- Solved
- No attempts yet
Problem
Once upon a time, Mavis studied at a vampire school. In computer science lessons, Mavis solved problems on various topics. One of her favorite topics is arrays.
Today is the array test at the vampire school. Mavis gets this problem: given an array , find a segment that maximizes .
is the largest number in the segment , and is the sum of the numbers in that segment.
Help Mavis solve this problem, because she really does not want to disappoint Dracula.
Input
The first line contains a natural number (). The next line contains numbers (), the array Mavis has.
Output
Print one integer on the first line: the largest value of that can be found in the array.
Hint
In the first sample, the answer is the segment .
In the second sample, the answer is the segment .