답안 #28269

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28269 2017-07-16T04:17:29 Z 뚜루루뚜루(#1212, onjo0127) 포도주 시음 (FXCUP2_wine) C++
1 / 1
99 ms 4364 KB
#include <bits/stdc++.h>
using namespace std;

long long arr[300009];

int main()
{
    int n,k;
    long long ans;
    scanf("%d %d",&n,&k); --k;
    for(int i=0; i<n; i++) scanf("%lld",&arr[i]);
    sort(arr, arr+n);
    ans = arr[n-1];
    for(int i=0; i<(n-2)-i && i<k/2; i++) ans += arr[n-2-i] - arr[i];
    printf("%lld",ans);
    return 0;
}

Compilation message

wine.cpp: In function 'int main()':
wine.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&k); --k;
                         ^
wine.cpp:11:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0; i<n; i++) scanf("%lld",&arr[i]);
                                                 ^
# 결과 실행 시간 메모리 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 3 ms 4364 KB Output is correct
18 Correct 6 ms 4364 KB Output is correct
19 Correct 9 ms 4364 KB Output is correct
20 Correct 9 ms 4364 KB Output is correct
21 Correct 13 ms 4364 KB Output is correct
22 Correct 29 ms 4364 KB Output is correct
23 Correct 29 ms 4364 KB Output is correct
24 Correct 26 ms 4364 KB Output is correct
25 Correct 99 ms 4364 KB Output is correct
26 Correct 96 ms 4364 KB Output is correct
27 Correct 86 ms 4364 KB Output is correct
28 Correct 59 ms 4364 KB Output is correct
29 Correct 79 ms 4364 KB Output is correct
30 Correct 89 ms 4364 KB Output is correct
31 Correct 83 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