제출 #28346

#제출 시각아이디문제언어결과실행 시간메모리
28346:thinking_face: (#68)포도주 시음 (FXCUP2_wine)C++11
1 / 1
109 ms3192 KiB
#include<bits/stdc++.h>

using namespace std;

int arr[300000];
long long ret = 0;

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	for(int i = 0; i < n; i++)
		scanf("%d", arr+i);
	sort(arr, arr+n);

	int l = 0, r = n-1;
	bool right = true;

	long long ret = 0;
	int prev = 0;
	while(k--)
	{
		if(right)
			ret += arr[r--] - prev;
		else
			prev = arr[l++];
		right = !right;
	}
	printf("%lld\n", ret);
	return 0;
}

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

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