Submission #28460

# Submission time Handle Problem Language Result Execution time Memory
28460 2017-07-16T06:10:53 Z 뚜룹뚜룹뚜룹뚜스~><(#1151, chan492811) Wine Tasting (FXCUP2_wine) C++11
0 / 1
0 ms 3460 KB
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;

int n, m;
ll res, now;
ll arr[300010];

int main(){
	int i;
	scanf("%d %d", &n, &m);
	for(i = 0; i < n; i++) scanf("%lld", &arr[i]);
	sort(arr, arr + n);
	for(i = 0; i < m; i += 2){
		res += arr[n - i / 2 - 1] - now;
		now = arr[i];
	}
	printf("%lld", res);
	return 0;
}

Compilation message

wine.cpp: In function 'int main()':
wine.cpp:12:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
                        ^
wine.cpp:13:47: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i = 0; i < n; i++) scanf("%lld", &arr[i]);
                                               ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3460 KB Output is correct
2 Correct 0 ms 3460 KB Output is correct
3 Incorrect 0 ms 3460 KB Output isn't correct
4 Halted 0 ms 0 KB -