Advertisement
Okorosso

бутылка на всех

Jun 16th, 2021
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <queue>
  2. #include <fstream>
  3.  
  4. void typicalEveningWithPMI(std::priority_queue<int> queue, long long int &sum, int sipCount) {
  5.     for (int i = 0; i < sipCount; ++i) {
  6.         int currOne = queue.top();
  7.         int remainder = currOne / 10;
  8.         queue.pop();
  9.         queue.push(remainder);
  10.         sum -= currOne;
  11.         sum += remainder;
  12.     }
  13. }
  14.  
  15. int main() {
  16.     std::ifstream fin("input.txt");
  17.     std::ofstream fout("output.txt");
  18.  
  19.     std::priority_queue<int> priorityQueue;
  20.     int bottleCount, sipCount;
  21.     long long int sum = 0;
  22.  
  23.     fin >> bottleCount >> sipCount;
  24.     for (int i = 0; i < bottleCount; ++i) {
  25.         int tmp;
  26.         fin >> tmp;
  27.         priorityQueue.push(tmp);
  28.         sum += tmp;
  29.     }
  30.  
  31.     typicalEveningWithPMI(priorityQueue, sum, sipCount);
  32.  
  33.     fout << sum;
  34.     return 0;
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement