Submission #28507

#TimeUsernameProblemLanguageResultExecution timeMemory
28507Shocking Hot (#68)포도주 시음 (FXCUP2_wine)C++14
1 / 1
106 ms4364 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:25: 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:22: 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...