Submission #28262

# Submission time Handle Problem Language Result Execution time Memory
28262 2017-07-16T04:15:45 Z 볼빨간 승관이(#1152, sys7961, deneb2016, hyorothy) Wine Tasting (FXCUP2_wine) C++11
1 / 1
79 ms 8364 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;
        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
1 Correct 0 ms 2180 KB Output is correct
2 Correct 0 ms 2180 KB Output is correct
3 Correct 0 ms 2180 KB Output is correct
4 Correct 0 ms 2180 KB Output is correct
5 Correct 0 ms 2180 KB Output is correct
6 Correct 0 ms 2180 KB Output is correct
7 Correct 0 ms 2180 KB Output is correct
8 Correct 0 ms 2180 KB Output is correct
9 Correct 0 ms 2180 KB Output is correct
10 Correct 0 ms 2180 KB Output is correct
11 Correct 0 ms 2180 KB Output is correct
12 Correct 0 ms 2180 KB Output is correct
13 Correct 0 ms 2340 KB Output is correct
14 Correct 0 ms 2340 KB Output is correct
15 Correct 0 ms 2340 KB Output is correct
16 Correct 0 ms 2340 KB Output is correct
17 Correct 0 ms 2600 KB Output is correct
18 Correct 3 ms 2600 KB Output is correct
19 Correct 3 ms 2600 KB Output is correct
20 Correct 3 ms 2600 KB Output is correct
21 Correct 13 ms 3756 KB Output is correct
22 Correct 19 ms 3756 KB Output is correct
23 Correct 19 ms 3756 KB Output is correct
24 Correct 23 ms 3756 KB Output is correct
25 Correct 69 ms 8364 KB Output is correct
26 Correct 69 ms 8364 KB Output is correct
27 Correct 66 ms 8364 KB Output is correct
28 Correct 46 ms 8364 KB Output is correct
29 Correct 63 ms 8364 KB Output is correct
30 Correct 79 ms 8364 KB Output is correct
31 Correct 69 ms 8364 KB Output is correct
32 Correct 66 ms 8364 KB Output is correct
33 Correct 0 ms 2180 KB Output is correct
34 Correct 6 ms 3756 KB Output is correct