답안 #28486

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28486 2017-07-16T06:33:16 Z Fe(#1116, minchurl) 포도주 시음 (FXCUP2_wine) C++
1 / 1
103 ms 3460 KB
#include<stdio.h>
#include<algorithm>
#define LL long long
using namespace std;
LL b[300005],minx,maxx;
int main(){
    LL n,k,i;
    scanf("%lld %lld",&n,&k);
    for(i=0;i<n;i++)    scanf("%lld",&b[i]);
    sort(b,b+n);
    if(k%2==0)  k--;
    for(i=0;i<k/2;i++)  minx+=b[i];
    k/=2;
    k++;
    for(i=n-1;i>=n-k;i--)   maxx+=b[i];
    printf("%lld\n",maxx-minx);
    return 0;
}

Compilation message

wine.cpp: In function 'int main()':
wine.cpp:8:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld",&n,&k);
                             ^
wine.cpp:9: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",&b[i]);
                                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3460 KB Output is correct
2 Correct 0 ms 3460 KB Output is correct
3 Correct 0 ms 3460 KB Output is correct
4 Correct 0 ms 3460 KB Output is correct
5 Correct 0 ms 3460 KB Output is correct
6 Correct 0 ms 3460 KB Output is correct
7 Correct 0 ms 3460 KB Output is correct
8 Correct 0 ms 3460 KB Output is correct
9 Correct 0 ms 3460 KB Output is correct
10 Correct 0 ms 3460 KB Output is correct
11 Correct 0 ms 3460 KB Output is correct
12 Correct 0 ms 3460 KB Output is correct
13 Correct 0 ms 3460 KB Output is correct
14 Correct 0 ms 3460 KB Output is correct
15 Correct 0 ms 3460 KB Output is correct
16 Correct 0 ms 3460 KB Output is correct
17 Correct 3 ms 3460 KB Output is correct
18 Correct 3 ms 3460 KB Output is correct
19 Correct 13 ms 3460 KB Output is correct
20 Correct 6 ms 3460 KB Output is correct
21 Correct 16 ms 3460 KB Output is correct
22 Correct 26 ms 3460 KB Output is correct
23 Correct 23 ms 3460 KB Output is correct
24 Correct 29 ms 3460 KB Output is correct
25 Correct 93 ms 3460 KB Output is correct
26 Correct 76 ms 3460 KB Output is correct
27 Correct 79 ms 3460 KB Output is correct
28 Correct 39 ms 3460 KB Output is correct
29 Correct 79 ms 3460 KB Output is correct
30 Correct 86 ms 3460 KB Output is correct
31 Correct 83 ms 3460 KB Output is correct
32 Correct 103 ms 3460 KB Output is correct
33 Correct 0 ms 3460 KB Output is correct
34 Correct 13 ms 3460 KB Output is correct