提交时间:2024-03-22 23:54:00

运行 ID: 139286

#include <bits/stdc++.h> using namespace std; int main() { priority_queue <int> q; int n, m; cin >> n >> m; for (int i = 1, x; i <= n; i++) cin >> x, q.push(-x); while (m--) { int tmp = q.top(); q.pop(); tmp = -tmp; q.push(tmp); } int s = 0; while (!q.empty()) { s += (-q.top()); q.pop(); } cout << s << endl; }