Submission #28346

#TimeUsernameProblemLanguageResultExecution timeMemory
28346:thinking_face: (#68)Wine Tasting (FXCUP2_wine)C++11
1 / 1
109 ms3192 KiB
#include<bits/stdc++.h> using namespace std; int arr[300000]; long long ret = 0; int main() { int n, k; scanf("%d %d", &n, &k); for(int i = 0; i < n; i++) scanf("%d", arr+i); sort(arr, arr+n); int l = 0, r = n-1; bool right = true; long long ret = 0; int prev = 0; while(k--) { if(right) ret += arr[r--] - prev; else prev = arr[l++]; right = !right; } printf("%lld\n", ret); return 0; }

Compilation message (stderr)

wine.cpp: In function 'int main()':
wine.cpp:11: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:13:21: 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...