# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74345 | 2018-08-31T10:54:49 Z | khsoo01 | Wine Tasting (FXCUP2_wine) | C++11 | 93 ms | 31200 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll n, k, a[300005]; int main() { scanf("%lld%lld",&n,&k); if(k%2 == 0) k--; for(ll i=1;i<=n;i++) { scanf("%lld",&a[i]); } sort(a+1, a+1+n); ll ans = 0; for(ll i=1;i<=(k+1)/2;i++) { ans += a[n-i+1]; } for(ll i=1;i<=k/2;i++) { ans -= a[i]; } printf("%lld\n",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 512 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 512 KB | Output is correct |
5 | Correct | 2 ms | 512 KB | Output is correct |
6 | Correct | 2 ms | 564 KB | Output is correct |
7 | Correct | 2 ms | 696 KB | Output is correct |
8 | Correct | 2 ms | 696 KB | Output is correct |
9 | Correct | 2 ms | 696 KB | Output is correct |
10 | Correct | 2 ms | 720 KB | Output is correct |
11 | Correct | 2 ms | 732 KB | Output is correct |
12 | Correct | 2 ms | 732 KB | Output is correct |
13 | Correct | 4 ms | 732 KB | Output is correct |
14 | Correct | 3 ms | 732 KB | Output is correct |
15 | Correct | 3 ms | 776 KB | Output is correct |
16 | Correct | 3 ms | 812 KB | Output is correct |
17 | Correct | 5 ms | 1132 KB | Output is correct |
18 | Correct | 8 ms | 1408 KB | Output is correct |
19 | Correct | 11 ms | 1716 KB | Output is correct |
20 | Correct | 10 ms | 2016 KB | Output is correct |
21 | Correct | 22 ms | 3568 KB | Output is correct |
22 | Correct | 32 ms | 4564 KB | Output is correct |
23 | Correct | 30 ms | 5524 KB | Output is correct |
24 | Correct | 30 ms | 6388 KB | Output is correct |
25 | Correct | 93 ms | 10772 KB | Output is correct |
26 | Correct | 89 ms | 13652 KB | Output is correct |
27 | Correct | 89 ms | 16664 KB | Output is correct |
28 | Correct | 52 ms | 19556 KB | Output is correct |
29 | Correct | 90 ms | 22404 KB | Output is correct |
30 | Correct | 88 ms | 25296 KB | Output is correct |
31 | Correct | 88 ms | 28276 KB | Output is correct |
32 | Correct | 91 ms | 31200 KB | Output is correct |
33 | Correct | 2 ms | 31200 KB | Output is correct |
34 | Correct | 18 ms | 31200 KB | Output is correct |