Submission #28422

#TimeUsernameProblemLanguageResultExecution timeMemory
28422일단아무거나적어놓은팀이름 (#68)Wine Tasting (FXCUP2_wine)C++14
1 / 1
96 ms3192 KiB
#include<cstdio> #include<iostream> #include<algorithm> using namespace std; int n, k, a[300001]; int main() { scanf("%d%d", &n, &k); for(int i = 0; i < n; ++i) { scanf("%d", a + i); } sort(a, a + n); long long res = a[n - 1]; for(int i = 0; i < (k - 1) / 2; ++i) { res += a[n - i - 2] - a[i]; } printf("%lld", res); return 0; }

Compilation message (stderr)

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