Submission #28283

#TimeUsernameProblemLanguageResultExecution timeMemory
28283ㅁㄴㅇㄹ (#68)Wine Tasting (FXCUP2_wine)C++98
1 / 1
96 ms3192 KiB
#include <bits/stdc++.h> using namespace std; int n, k, i, T[300010]; long long res=0; int main(){ scanf("%d%d", &n, &k); for(i=0; i<n; i++) scanf("%d", T+i); sort(T, T+n); for(i=0; i<k; i++){ if(i%2==0) res+=T[n-i/2-1]; else res-=T[i/2]; } if((k-1)%2==1) res+=T[(k-1)/2]; printf("%lld", res); return 0; }

Compilation message (stderr)

wine.cpp: In function 'int main()':
wine.cpp:6: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:8:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", T+i);
                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...