Submission #28260

#TimeUsernameProblemLanguageResultExecution timeMemory
28260Sorry AcornCkiGuiziTeam (#68)Wine Tasting (FXCUP2_wine)C++14
1 / 1
103 ms2288 KiB
#include <cstdio> #include <algorithm> using namespace std; int a[300003]; int main() { long long r = 0; int i, n, m; scanf("%d%d", &n, &m); for (i = 1; i <= n; i++) scanf("%d", &a[i]); sort(a, a + n + 1); for (i = 0; i + i < m; i++) r += a[n - i] - a[i]; printf("%lld", r); return 0; }

Compilation message (stderr)

wine.cpp: In function 'int main()':
wine.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
                       ^
wine.cpp:12:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
                                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...