Submission #28465

#TimeUsernameProblemLanguageResultExecution timeMemory
28465뚜룹뚜룹뚜룹뚜스~>< (#68)Wine Tasting (FXCUP2_wine)C++98
1 / 1
96 ms3460 KiB
#include <cstdio> #include <algorithm> #define ll long long using namespace std; int n, m; ll res, now; ll arr[300010]; int main(){ int i; scanf("%d %d", &n, &m); for(i = 0; i < n; i++) scanf("%lld", &arr[i]); sort(arr, arr + n); for(i = 0; i < m; i += 2){ res += arr[n - i / 2 - 1] - now; now = arr[i / 2]; } printf("%lld", res); return 0; }

Compilation message (stderr)

wine.cpp: In function 'int main()':
wine.cpp:12:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
                        ^
wine.cpp:13:47: 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...