# 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; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up