Submission #28315

#TimeUsernameProblemLanguageResultExecution timeMemory
28315ㅁㄴㅇㄹ호 (#68)Wine Tasting (FXCUP2_wine)C++14
0 / 1
0 ms2288 KiB
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <tuple>

using namespace std;

int arr[300000];

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];

    k = min(k, (n-1)/2 + 1);

    for(i = 1; i<k; i++)
    {
        if(i % 2 == 0)
            res += arr[n-1-i/2] - arr[i/2-1];
    }
    printf("%lld", res);
    return 0;
}

Compilation message (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...