eolymp
bolt
Try our new interface for solving problems
Problems

Light Emitting Hindenburg

Light Emitting Hindenburg

Lothar is organizing a concert tour of his friends’ rock band. The tour will take place in November and each day there will be at most one concert. The tour will be very representative and many musicians are willing to take part in it. The number of musicians in the tour is strictly prescribed and cannot be changed. Each concert on the tour must be attended by all the musicians taking part in the tour. The good news for Lothar is that the number of candidate musicians is at least as big as the prescribed number of musicians in the tour. The bad news is that a typical musician is not available during the whole month and that various musicians’ schedules differ a lot from each other. Long ago, Lothar wrote a core of a computer scheduling system, and he is exploiting it now to organize the tour. He repeatedly and somewhat randomly chooses a group of musicians of prescribed size, and lets the system calculate an acceptable tour schedule. The system depends on a very specific data format. The schedules of musicians and the tour schedules are represented as numerical codes. The days in November are labeled by their numbers in the month: $1, 2, ..., 30$. For a given musician, each November day is assigned a particular numerical code. A day with label $l$ is coded by integer $2^{30- l}$ if the musician is available on that day. Otherwise, the day is coded by $0$. The musician schedule code is the sum of all his or her day codes. For a given group of musicians, each November day is assigned a particular numerical code. A day with label $l$ is coded by integer $2^{30−l}$ if all musicians in the group are available on that day. Otherwise, the day is coded by $0$. The group availability code is the sum of all day codes of the group. For many additional subtle reasons, Lothar thinks that the best tour would be the one with the highest possible value of the availability code of the group of musicians taking part in it. \InputFile The first line contains two integers $n, k~(1 \le k \le n \le 2 \cdot 10^5)$. $n$ is the number of available musicians, $k$ is the prescribed number of musicians taking part in the tour. The next line contains a sequence of $n$ positive integers. Each integer in the sequence represents a code of a schedule of one musician. The codes are listed in arbitrary order. \OutputFile Print the best possible availability code of any group of $k$ musicians.
Time limit 1 second
Memory limit 128 MiB
Input example #1
5 2
6 15 9 666 1
Output example #1
10
Input example #2
8 4
13 30 27 20 11 30 19 10
Output example #2
18
Source 2019 ACM Central Europe (CERC), Prague, November 29 - December 1, Problem G