oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

xorpies Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

xorpies.html

Problem Description

Peanut's endless fascination with pies has ended up with him organising a huge pie party! As the party name suggests, Peanut will buy MANY MANY pies and then eat them! Pies are extremely awesome, but Peanut has found a way to make pies EVEN MORE AWESOME! The awesomeness of the huge pie party is defined by the awesomeness index of the pies.

At the pie party, the pies will be arranged into a row. There are N different types of pie Peanut can order, each of them with a different size. Peanut can order any amount of each type of pie for the party, but the total number of pies for the party must be equal to P. Since the pies will be arranged in a row, some pairs of pies will be adjacent to each other. Take two adjacent pies with size A and B. The awesomeness index of this pair of pies will be defined as A xor B. The awesomeness index of this entire chain of pies will be the sum of the awesomeness index of all adjacent pairs of pies.

Given the sizes of pies Peanut can order, output the maximum awesomeness index of the pies if Peanut chooses and arranges the pies optimally.

Input

The first line of input will contain two integers, N and P.
The second line of input will contain N integers, with each integer representing the size of one possible type of pie Peanut can buy.

Output

Your output should contain one integer, the maximum awesomeness index of the pies.

Limits

Subtask 1 (13%): 1 ≤ N, P ≤ 10. All of the pie sizes will less than 10.
Subtask 2 (19%): 1 ≤ N, P ≤ 1000. All of the pie sizes will be less than 1024.
Subtask 3 (25%): 1 ≤ N, P ≤ 100000. All of the pie sizes will be less than 1024.
Subtask 4 (43%): 1 ≤ N ≤ 100000. 1 ≤ P ≤ 231-1. All of the pie sizes will fit into a 32-bit signed integer.
Subtask 5 (0%): As per sample testcases.

Sample Input 1

4 2
2 3 5 7

Sample Output 1

7

Explanation of Sample 1

Arranging it in the form 5 -- 2 will give an awesomeness index of 7 (2 xor 5).

Tags

Ad Hoc

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
113501s32MBMinimum
2191001s32MBMinimum
3251501s32MBMinimum
4432001s32MBMinimum
5011s32MBMinimum

Judge Compile Command

g++-8 ans.cpp -o xorpies -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.