Submission #28243

#TimeUsernameProblemLanguageResultExecution timeMemory
28243xhae (#68)Wine Tasting (FXCUP2_wine)C++14
1 / 1
113 ms3460 KiB
#include <cstdio> #include <algorithm> using namespace std; long long data[300000]; int main(void) { int n, m; scanf("%d %d", &n, &m); for(int i = 0; i < n; i++) scanf("%lld", data + i); sort(data, data + n); long long ans = data[n - 1]; int si = 0, ei = n - 2; for(int i = 1; i < m; i++) { if(i % 2 == 1) si++; else ans += data[ei--] - data[si - 1]; } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

wine.cpp: In function 'int main()':
wine.cpp:10: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:11:52: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < n; i++) scanf("%lld", data + i);
                                                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...