Q2530.h 466 B

1234567891011121314151617181920212223242526
  1. //
  2. // Created by 李洋 on 2023/10/18.
  3. //
  4. #ifndef LEECODE_C_Q2530_H
  5. #define LEECODE_C_Q2530_H
  6. #include <vector>
  7. #include <queue>
  8. using namespace std;
  9. long long maxKelements(vector<int> &nums, int k) {
  10. long long count = 0;
  11. priority_queue<int> Q(nums.begin(), nums.end());
  12. while (k) {
  13. auto top = Q.top();
  14. Q.pop();
  15. count += top;
  16. Q.push(ceil(top / 3.0));
  17. k--;
  18. }
  19. return count;
  20. }
  21. #endif //LEECODE_C_Q2530_H
备用站点 当前处于降级运行的备用站点,仅供应急访问,数据和功能可能不是最新。