답안 #28331

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28331 2017-07-16T04:46:14 Z lyzqm123(#1136, lyzqm123) 포도주 시음 (FXCUP2_wine) C++11
0 / 1
0 ms 2288 KB
#include <cstdio>
#include <algorithm>
using namespace std;
int arr[300001];
int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	for (int n = 0;n < N;n++) scanf("%d", &arr[n]);
	sort(arr, arr + N);
	long long ans = arr[N - 1];
	if (N >= 2 && K > 2)
		ans += arr[N - 2] - arr[0];
	printf("%lld\n", ans);
	return 0;
}

Compilation message

wine.cpp: In function 'int main()':
wine.cpp:7: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:8:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int n = 0;n < N;n++) scanf("%d", &arr[n]);
                                                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2288 KB Output is correct
2 Correct 0 ms 2288 KB Output is correct
3 Incorrect 0 ms 2288 KB Output isn't correct
4 Halted 0 ms 0 KB -