Tap here to switch tabs
Problem
Submissions

Problem: Maximum Bitwise AND After Increment Operations

Try to solve the Maximum Bitwise AND After Increment Operations problem.

Statement

You are given an integer array nums of length n, and two integers k and m.

In one operation, you can choose any element in nums and increment its value by 11. You can perform at most k operations in total across all elements.

Your goal is to select a subset of m elements from nums such that after performing at most k operations, the bitwise AND of the selected m elements is maximized.

Return the maximum possible bitwise AND of the chosen m elements.

Constraints:

  • 1≤n==1 \leq n == nums.length ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤109\leq 10^9

  • 1≤1 \leq m ≤n\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Bitwise AND After Increment Operations

Try to solve the Maximum Bitwise AND After Increment Operations problem.

Statement

You are given an integer array nums of length n, and two integers k and m.

In one operation, you can choose any element in nums and increment its value by 11. You can perform at most k operations in total across all elements.

Your goal is to select a subset of m elements from nums such that after performing at most k operations, the bitwise AND of the selected m elements is maximized.

Return the maximum possible bitwise AND of the chosen m elements.

Constraints:

  • 1≤n==1 \leq n == nums.length ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤109\leq 10^9

  • 1≤1 \leq m ≤n\leq n