---
# System prepended metadata

title: 2530. Maximal Score After Applying K Operations
tags: [Leetcode, Priority Queue, Medium]

---

# 2530. Maximal Score After Applying K Operations
###### tags: `Leetcode` `Medium` `Priority Queue`
Link: https://leetcode.com/problems/maximal-score-after-applying-k-operations/
## Code
```java=
class Solution {
    public long maxKelements(int[] nums, int k) {
        Queue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
        for(int num:nums) pq.add(num);
        long score = 0;
        for(int i=0; i<k; i++){
            int num = pq.poll();
            score += num;
            pq.add((num+2)/3);
        }
        return score;
    }
}
```