mirror of
				https://git.wolves.top/wolves/leetcode.git
				synced 2025-11-04 17:26:32 +08:00 
			
		
		
		
	init
This commit is contained in:
		
							
								
								
									
										26
									
								
								23/10/Q2530.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								23/10/Q2530.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
//
 | 
			
		||||
// Created by 李洋 on 2023/10/18.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#ifndef LEECODE_C_Q2530_H
 | 
			
		||||
#define LEECODE_C_Q2530_H
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <queue>
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
long long maxKelements(vector<int> &nums, int k) {
 | 
			
		||||
    long long count = 0;
 | 
			
		||||
    priority_queue<int> Q(nums.begin(), nums.end());
 | 
			
		||||
    while (k) {
 | 
			
		||||
        auto top = Q.top();
 | 
			
		||||
        Q.pop();
 | 
			
		||||
        count += top;
 | 
			
		||||
        Q.push(ceil(top / 3.0));
 | 
			
		||||
        k--;
 | 
			
		||||
    }
 | 
			
		||||
    return count;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif //LEECODE_C_Q2530_H
 | 
			
		||||
		Reference in New Issue
	
	Block a user