# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28477 | 맞왜틀 맞왜틀 신나는노래~ 헤이! 나도한번 불러보자 (#68) | Wine Tasting (FXCUP2_wine) | C++98 | 116 ms | 6260 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 <cstdio>
#include <algorithm>
#include <vector>
int main(){
int N,K;
scanf("%d%d",&N,&K);
std::vector<int> D(N+1);
for(int i =1 ; i <= N; i++){
scanf("%d",&D[i]);
}
std::sort(D.begin(),D.end());
std::vector<int> ans;
long long tot = 0;
for(int i = 0; i<= K; i++){
if(i%2 == 1){
ans.push_back(D[D.size()-i/2-1]);
}else ans.push_back(D[i/2]);
if(ans.size() >= 2 && ans.back() - ans[ans.size()-2]>= 0){
tot += ans.back() - ans[ans.size()-2];
}
}
printf("%lld",tot);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |