Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <queue>
- #include <fstream>
- void typicalEveningWithPMI(std::priority_queue<int> queue, long long int &sum, int sipCount) {
- for (int i = 0; i < sipCount; ++i) {
- int currOne = queue.top();
- int remainder = currOne / 10;
- queue.pop();
- queue.push(remainder);
- sum -= currOne;
- sum += remainder;
- }
- }
- int main() {
- std::ifstream fin("input.txt");
- std::ofstream fout("output.txt");
- std::priority_queue<int> priorityQueue;
- int bottleCount, sipCount;
- long long int sum = 0;
- fin >> bottleCount >> sipCount;
- for (int i = 0; i < bottleCount; ++i) {
- int tmp;
- fin >> tmp;
- priorityQueue.push(tmp);
- sum += tmp;
- }
- typicalEveningWithPMI(priorityQueue, sum, sipCount);
- fout << sum;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement