AmazonOA #85
Get Max Rating (Bitwise AND Subset)
估计困难可在线判题
Perform at most k operations, each adding 1 to any rating. After the changes, choose exactly m items and maximize their bitwise AND.
输入格式
The first line contains n k m (1≤m≤n≤100000, 1≤k≤10⁹); the second line contains n rating values (1..10⁹).
输出格式
Output a single integer answer.
样例 1
输入:
2 2 2
1 2
输出:
2
样例 2
输入:
1 3 1
5
输出:
8
样例 3
输入:
3 2 3
1 1 1
输出:
1
样例说明
Example 1: raise 1 to 2 and choose two items, giving an AND of 2; bringing both items to 3 takes 3 operations, which exceeds the budget. Example 2: the only value goes from 5 to 8, so the answer is 8. Example 3: bringing all three items to 2 takes 3 operations but the budget is only 2, so the maximum AND stays 1.