0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 05:38:47 +00:00

#16. 淘淘蓝蓝之地主的硬币

https://sjzezoj.com/submission/21923
This commit is contained in:
Baoshuo Ren 2021-08-24 16:13:38 +08:00 committed by Baoshuo Ren
parent 4f6248c621
commit 80c012b77b
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

22
S2OJ/16/16.cpp Normal file
View File

@ -0,0 +1,22 @@
#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;
}