# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28262 | 볼빨간 승관이 (#68) | Wine Tasting (FXCUP2_wine) | C++11 | 79 ms | 8364 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 <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <unordered_map>
#include <list>
#include <unordered_set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define INFI 987654321
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
int N, K;
vector<ll> data;
int main() {
ios_base::sync_with_stdio(false);
cin >> N >> K;
for(int i = 0; i < N; ++i) {
ll here;
cin >> here;
data.push_back(here);
}
sort(data.begin(), data.end());
ll ans = 0;
int cur = 0;
while(K > 1) {
K -= 2;
if(K == 0)
ans += data.back();
else
ans += data.back() - data[cur++];
data.pop_back();
}
if(K) {
ans += data.back();
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |