제출 #28486

#제출 시각아이디문제언어결과실행 시간메모리
28486Fe (#68)포도주 시음 (FXCUP2_wine)C++98
1 / 1
103 ms3460 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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]);
                                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...