# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28322 | 2017-07-16T04:41:15 Z | ㅁㄴㅇㄹ호(#1227, gs13105) | 포도주 시음 (FXCUP2_wine) | C++14 | 109 ms | 2288 KB |
#include <stdio.h> #include <cstdlib> #include <cstring> #include <algorithm> #include <numeric> #include <string> #include <vector> #include <tuple> using namespace std; int arr[300010]; int main() { //freopen("in", "r", stdin); //freopen("out", "w", stdout); int n, k, i; long long res; scanf("%d%d", &n, &k); for(i = 0; i<n; i++) scanf("%d", &arr[i]); sort(arr, arr+n); res = arr[n-1]; for(i = 1; i<k; i++) { if(n-1-i/2 <= i/2-1) break; if(i % 2 == 0) res += 0LL + arr[n-1-i/2] - arr[i/2-1]; } printf("%lld", res); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2288 KB | Output is correct |
2 | Correct | 0 ms | 2288 KB | Output is correct |
3 | Correct | 0 ms | 2288 KB | Output is correct |
4 | Correct | 0 ms | 2288 KB | Output is correct |
5 | Correct | 0 ms | 2288 KB | Output is correct |
6 | Correct | 0 ms | 2288 KB | Output is correct |
7 | Correct | 0 ms | 2288 KB | Output is correct |
8 | Correct | 0 ms | 2288 KB | Output is correct |
9 | Correct | 0 ms | 2288 KB | Output is correct |
10 | Correct | 0 ms | 2288 KB | Output is correct |
11 | Correct | 0 ms | 2288 KB | Output is correct |
12 | Correct | 0 ms | 2288 KB | Output is correct |
13 | Correct | 0 ms | 2288 KB | Output is correct |
14 | Correct | 0 ms | 2288 KB | Output is correct |
15 | Correct | 0 ms | 2288 KB | Output is correct |
16 | Correct | 0 ms | 2288 KB | Output is correct |
17 | Correct | 3 ms | 2288 KB | Output is correct |
18 | Correct | 3 ms | 2288 KB | Output is correct |
19 | Correct | 6 ms | 2288 KB | Output is correct |
20 | Correct | 6 ms | 2288 KB | Output is correct |
21 | Correct | 13 ms | 2288 KB | Output is correct |
22 | Correct | 26 ms | 2288 KB | Output is correct |
23 | Correct | 26 ms | 2288 KB | Output is correct |
24 | Correct | 23 ms | 2288 KB | Output is correct |
25 | Correct | 89 ms | 2288 KB | Output is correct |
26 | Correct | 79 ms | 2288 KB | Output is correct |
27 | Correct | 106 ms | 2288 KB | Output is correct |
28 | Correct | 69 ms | 2288 KB | Output is correct |
29 | Correct | 96 ms | 2288 KB | Output is correct |
30 | Correct | 73 ms | 2288 KB | Output is correct |
31 | Correct | 79 ms | 2288 KB | Output is correct |
32 | Correct | 109 ms | 2288 KB | Output is correct |
33 | Correct | 0 ms | 2288 KB | Output is correct |
34 | Correct | 16 ms | 2288 KB | Output is correct |