# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74345 | khsoo01 | Wine Tasting (FXCUP2_wine) | C++11 | 93 ms | 31200 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k, a[300005];
int main()
{
scanf("%lld%lld",&n,&k);
if(k%2 == 0) k--;
for(ll i=1;i<=n;i++) {
scanf("%lld",&a[i]);
}
sort(a+1, a+1+n);
ll ans = 0;
for(ll i=1;i<=(k+1)/2;i++) {
ans += a[n-i+1];
}
for(ll i=1;i<=k/2;i++) {
ans -= a[i];
}
printf("%lld\n",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |