제출 #28259

#제출 시각아이디문제언어결과실행 시간메모리
28259tlwpdus 팬클럽 회장 (#68)Wine Tasting (FXCUP2_wine)C++14
1 / 1
106 ms4364 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, k;
ll a[300010], ans;

int main(){
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++){
		scanf("%lld", a + i);
	}
	sort(a + 1, a + n + 1);
	if(k == 1){
		printf("%lld\n", a[n]);
		return 0;
	}
	k = (k + 1) / 2;
	for(int i = 1; i <= k; i++){
		if(i == 1) ans += a[n + 1 - i];
		else ans += a[n + 1 - i] - a[i - 1];
	}
	printf("%lld\n", ans);
}

컴파일 시 표준 에러 (stderr) 메시지

wine.cpp: In function 'int main()':
wine.cpp:9: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:11:23: 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...