Submission #74345

#TimeUsernameProblemLanguageResultExecution timeMemory
74345khsoo01Wine Tasting (FXCUP2_wine)C++11
1 / 1
93 ms31200 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll n, k, a[300005]; int main() { scanf("%lld%lld",&n,&k); if(k%2 == 0) k--; for(ll i=1;i<=n;i++) { scanf("%lld",&a[i]); } sort(a+1, a+1+n); ll ans = 0; for(ll i=1;i<=(k+1)/2;i++) { ans += a[n-i+1]; } for(ll i=1;i<=k/2;i++) { ans -= a[i]; } printf("%lld\n",ans); }

Compilation message (stderr)

wine.cpp: In function 'int main()':
wine.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~
wine.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...