#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
//freopen ("blocks.in","r",stdin);
//freopen ("blocks.out","w",stdout);
int n,k,i,a[100010],ans=0;
cin>>n>>k;
for (i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
for (i=0;i<min(n,k)-1;i++)
{
ans+=a[i];
}
ans+=a[n-1];
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1988 KB |
Output is correct |
2 |
Correct |
0 ms |
1984 KB |
Output is correct |
3 |
Correct |
0 ms |
1984 KB |
Output is correct |
4 |
Correct |
0 ms |
1984 KB |
Output is correct |
5 |
Correct |
0 ms |
1988 KB |
Output is correct |
6 |
Correct |
0 ms |
1988 KB |
Output is correct |
7 |
Incorrect |
0 ms |
1984 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |