Untitled
unknown
plain_text
9 months ago
657 B
6
Indexable
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main() {
int t, n;
cin >> t;
while (t--) {
cin >> n;
priority_queue<int> vect;
for (int j = 0; j < n; j++) {
int x;
cin >> x;
vect.push(x);
}
while (vect.size() != 1) {
int a = vect.top();
vect.pop();
int b = vect.top();
vect.pop();
int c = a + b - 1;
vect.push(c);
}
cout << vect.top() << '\n';
}
return 0;
}
Editor is loading...
Leave a Comment