Submission #28275

# Submission time Handle Problem Language Result Execution time Memory
28275 2017-07-16T04:20:27 Z ㅁㄴㅇㄹ(#1150, TAMREF, Diuven, suhgyuho_william) Wine Tasting (FXCUP2_wine) C++
0 / 1
0 ms 3192 KB
#include <bits/stdc++.h>
using namespace std;
int n, k, i, T[300010];
long long res=0;
int main(){
	scanf("%d%d", &n, &k);
	for(i=0; i<n; i++)
		scanf("%d", T+i);
	sort(T, T+n);
	for(i=0; i<k; i++){
		if(i%2==0)
			res+=T[n-i/2-1];
		else
			res-=T[i/2];
	}
	printf("%lld", res);
	return 0;
}

Compilation message

wine.cpp: In function 'int main()':
wine.cpp:6: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:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", T+i);
                   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3192 KB Output is correct
2 Incorrect 0 ms 3192 KB Output isn't correct
3 Halted 0 ms 0 KB -