제출 #28322

#제출 시각아이디문제언어결과실행 시간메모리
28322ㅁㄴㅇㄹ호 (#68)포도주 시음 (FXCUP2_wine)C++14
1 / 1
109 ms2288 KiB
#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;
}

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

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