제출 #74345

#제출 시각아이디문제언어결과실행 시간메모리
74345khsoo01포도주 시음 (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);
}

컴파일 시 표준 에러 (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...