제출 #28237

#제출 시각아이디문제언어결과실행 시간메모리
28237슈퍼스타 tlwpdus (#68)Wine Tasting (FXCUP2_wine)C++11
1 / 1
93 ms4364 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, k;
ll arr[300100];

int main() {
    int i;

    scanf("%d%d",&n,&k);
    for (i=0;i<n;i++) scanf("%lld",&arr[i]);
    sort(arr,arr+n);
    if (k%2==0) k--;
    ll sum = 0;
    for (i=0;i<(k-1)/2;i++) sum -= arr[i];
    for (i=n-1;i>n-1-(k+1)/2;i--) sum += arr[i];
    printf("%lld\n",sum);

    return 0;
}

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

wine.cpp: In function 'int main()':
wine.cpp:13:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
                        ^
wine.cpp:14: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",&arr[i]);
                                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...