# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28283 | 2017-07-16T04:23:33 Z | ㅁㄴㅇㄹ(#1150, TAMREF, Diuven, suhgyuho_william) | Wine Tasting (FXCUP2_wine) | C++ | 96 ms | 3192 KB |
#include <bits/stdc++.h> using namespace std; int n, k, i, T[300010]; long long res=0; int main(){ scanf("%d%d", &n, &k); for(i=0; i<n; i++) scanf("%d", T+i); sort(T, T+n); for(i=0; i<k; i++){ if(i%2==0) res+=T[n-i/2-1]; else res-=T[i/2]; } if((k-1)%2==1) res+=T[(k-1)/2]; printf("%lld", res); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3192 KB | Output is correct |
2 | Correct | 0 ms | 3192 KB | Output is correct |
3 | Correct | 0 ms | 3192 KB | Output is correct |
4 | Correct | 0 ms | 3192 KB | Output is correct |
5 | Correct | 0 ms | 3192 KB | Output is correct |
6 | Correct | 0 ms | 3192 KB | Output is correct |
7 | Correct | 0 ms | 3192 KB | Output is correct |
8 | Correct | 0 ms | 3192 KB | Output is correct |
9 | Correct | 0 ms | 3192 KB | Output is correct |
10 | Correct | 0 ms | 3192 KB | Output is correct |
11 | Correct | 0 ms | 3192 KB | Output is correct |
12 | Correct | 0 ms | 3192 KB | Output is correct |
13 | Correct | 0 ms | 3192 KB | Output is correct |
14 | Correct | 0 ms | 3192 KB | Output is correct |
15 | Correct | 0 ms | 3192 KB | Output is correct |
16 | Correct | 0 ms | 3192 KB | Output is correct |
17 | Correct | 3 ms | 3192 KB | Output is correct |
18 | Correct | 3 ms | 3192 KB | Output is correct |
19 | Correct | 9 ms | 3192 KB | Output is correct |
20 | Correct | 6 ms | 3192 KB | Output is correct |
21 | Correct | 13 ms | 3192 KB | Output is correct |
22 | Correct | 39 ms | 3192 KB | Output is correct |
23 | Correct | 26 ms | 3192 KB | Output is correct |
24 | Correct | 26 ms | 3192 KB | Output is correct |
25 | Correct | 83 ms | 3192 KB | Output is correct |
26 | Correct | 96 ms | 3192 KB | Output is correct |
27 | Correct | 76 ms | 3192 KB | Output is correct |
28 | Correct | 39 ms | 3192 KB | Output is correct |
29 | Correct | 76 ms | 3192 KB | Output is correct |
30 | Correct | 76 ms | 3192 KB | Output is correct |
31 | Correct | 96 ms | 3192 KB | Output is correct |
32 | Correct | 83 ms | 3192 KB | Output is correct |
33 | Correct | 0 ms | 3192 KB | Output is correct |
34 | Correct | 23 ms | 3192 KB | Output is correct |