Submission #28251

# Submission time Handle Problem Language Result Execution time Memory
28251 2017-07-16T04:11:16 Z 볼빨간 승관이(#1152, sys7961, deneb2016, hyorothy) Wine Tasting (FXCUP2_wine) C++11
0 / 1
0 ms 2180 KB
#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;
        ans += data.back() - data[cur++];
        data.pop_back();
    }
    if(K) {
        ans += data.back();
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2180 KB Output is correct
2 Incorrect 0 ms 2180 KB Output isn't correct
3 Halted 0 ms 0 KB -