Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
139286 | 吴晨曦 | K 次取反后最大化的数组和 | C++ | 通过 | 100 | 0 MS | 252 KB | 357 | 2024-03-22 23:54:00 |
#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; }