Submission #28262

#TimeUsernameProblemLanguageResultExecution timeMemory
28262볼빨간 승관이 (#68)Wine Tasting (FXCUP2_wine)C++11
1 / 1
79 ms8364 KiB
#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 timeMemoryGrader output
Fetching results...