Submission #28265

#TimeUsernameProblemLanguageResultExecution timeMemory
28265not good but never sad (#68)Wine Tasting (FXCUP2_wine)C++98
1 / 1
119 ms2288 KiB
#include <stdio.h> #include <algorithm> using namespace std; int A[300300]; int main() { int N,K,c; scanf ("%d %d",&N,&K); for (int i=0;i<N;i++) scanf ("%d",&A[i]); sort(A,A+N); long long ans = 0; for (int i=0,j=N-1,c=0;c<K;c++){ if (c % 2 == 0){ ans += A[j] - (i ? A[i-1] : 0); i++; j--; } } printf ("%lld\n",ans); return 0; }

Compilation message (stderr)

wine.cpp: In function 'int main()':
wine.cpp:9:10: warning: unused variable 'c' [-Wunused-variable]
  int N,K,c;
          ^
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,&K);
                       ^
wine.cpp:12:42: 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 ("%d",&A[i]);
                                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...