Submission #28237

# Submission time Handle Problem Language Result Execution time Memory
28237 2017-07-16T04:05:50 Z 슈퍼스타 tlwpdus(#1124, tlwpdus) Wine Tasting (FXCUP2_wine) C++11
1 / 1
93 ms 4364 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, k;
ll arr[300100];

int main() {
    int i;

    scanf("%d%d",&n,&k);
    for (i=0;i<n;i++) scanf("%lld",&arr[i]);
    sort(arr,arr+n);
    if (k%2==0) k--;
    ll sum = 0;
    for (i=0;i<(k-1)/2;i++) sum -= arr[i];
    for (i=n-1;i>n-1-(k+1)/2;i--) sum += arr[i];
    printf("%lld\n",sum);

    return 0;
}

Compilation message

wine.cpp: In function 'int main()':
wine.cpp:13:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
                        ^
wine.cpp:14:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i=0;i<n;i++) scanf("%lld",&arr[i]);
                                            ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4364 KB Output is correct
2 Correct 0 ms 4364 KB Output is correct
3 Correct 0 ms 4364 KB Output is correct
4 Correct 0 ms 4364 KB Output is correct
5 Correct 0 ms 4364 KB Output is correct
6 Correct 0 ms 4364 KB Output is correct
7 Correct 0 ms 4364 KB Output is correct
8 Correct 0 ms 4364 KB Output is correct
9 Correct 0 ms 4364 KB Output is correct
10 Correct 0 ms 4364 KB Output is correct
11 Correct 0 ms 4364 KB Output is correct
12 Correct 0 ms 4364 KB Output is correct
13 Correct 0 ms 4364 KB Output is correct
14 Correct 0 ms 4364 KB Output is correct
15 Correct 0 ms 4364 KB Output is correct
16 Correct 0 ms 4364 KB Output is correct
17 Correct 0 ms 4364 KB Output is correct
18 Correct 3 ms 4364 KB Output is correct
19 Correct 6 ms 4364 KB Output is correct
20 Correct 6 ms 4364 KB Output is correct
21 Correct 13 ms 4364 KB Output is correct
22 Correct 26 ms 4364 KB Output is correct
23 Correct 26 ms 4364 KB Output is correct
24 Correct 26 ms 4364 KB Output is correct
25 Correct 69 ms 4364 KB Output is correct
26 Correct 93 ms 4364 KB Output is correct
27 Correct 83 ms 4364 KB Output is correct
28 Correct 79 ms 4364 KB Output is correct
29 Correct 79 ms 4364 KB Output is correct
30 Correct 76 ms 4364 KB Output is correct
31 Correct 76 ms 4364 KB Output is correct
32 Correct 86 ms 4364 KB Output is correct
33 Correct 0 ms 4364 KB Output is correct
34 Correct 13 ms 4364 KB Output is correct