0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 17:56:28 +00:00
OI-codes/S2OJ/16/16.cpp

23 lines
421 B
C++

#include <bits/stdc++.h>
using namespace std;
long long t, n, k, a[5005], ans;
int main() {
cin >> t;
while (t--) {
ans = 0;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n, greater<long long>());
for (int i = k; i < n; i++) {
ans += a[i];
}
cout << max(ans, a[0]) << endl;
}
return 0;
}