P9612 [CERC2019] Light Emitting Hindenburg
Background
**This problem is translated from [CERC 2019](https://contest.felk.cvut.cz/19cerc/solved.html) “[Light Emitting Hindenburg](https://contest.felk.cvut.cz/19cerc/solved/hindenburg.pdf)”.**
Description
Lothar is organizing a concert tour for his friends’ rock band. The tour will take place in November, with at most one concert per day. This tour is going to be very special, and many musicians are willing to join. The number of musicians on the tour is strictly fixed and cannot be changed. Every concert in the tour must have all musicians participating in the tour.
The good news for Lothar is that the number of candidate musicians is at least as large as the required number of musicians on the tour. The bad news is that a typical musician is not available for the whole month, and different musicians have very different schedules.
A long time ago, Lothar wrote the core of a computer scheduling system, and now he is using it to organize this tour. He repeatedly, somewhat randomly, chooses a group of musicians of the required size and asks the system to compute an acceptable tour schedule. The system depends on a very specific data format. Musicians’ schedules and tour schedules are represented by numerical codes. The days in November are labeled by their day numbers in the month: $1, 2, \dots, 30$.
For a given musician, each day in November of each year is assigned a specific numerical code. If the musician is available on that day, then the day labeled $L$ is encoded by the integer $2^{30-L}$. Otherwise, the day is encoded by $0$. A musician’s schedule code is the sum of the codes of all their days.
For a given group of musicians, each day in November of each year is assigned a specific numerical code. If all musicians in the group are available on that day, then the day labeled $L$ is encoded by the integer $2^{30-L}$. Otherwise, the day is encoded by $0$. The group’s availability code is the sum of the codes of all its day codes.
For many other subtle reasons, Lothar believes the best tour should be any group of musicians whose availability code is as large as possible.
Input Format
The first line contains two integers $N, K\ (1\le K\le N\le 2\times 10^5)$. $N$ is the number of available musicians, and $K$ is the required number of musicians to participate in the tour.
The second line contains a sequence of $N$ positive integers. Each integer in the sequence represents a musician’s schedule code. The codes are listed in arbitrary order.
Output Format
Output one integer, the maximum possible value of the availability code for a group of $K$ musicians.
Explanation/Hint
Translated by ChatGPT 5