mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 15:36:27 +00:00
23 lines
421 B
C++
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;
|
|
}
|