Tap here to switch tabs
Problem
Submissions

Problem: Maximum Bitwise AND After Increment Operations

Maximum Bitwise AND After Increment Operations asks you to choose m elements from an integer array, use at most k increments, and return the largest possible bitwise AND.

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 ≤5×104\leq 5 \times 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

Maximum Bitwise AND After Increment Operations asks you to choose m elements from an integer array, use at most k increments, and return the largest possible bitwise AND.

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 ≤5×104\leq 5 \times 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