Submission #28788

# Submission time Handle Problem Language Result Execution time Memory
28788 2017-07-17T07:49:03 Z kriii Wine Tasting (FXCUP2_wine) C++14
1 / 1
103 ms 2288 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
 
int A[300300];
 
int main()
{
	int N,K,c;
 
	scanf ("%d %d",&N,&K);
	for (int i=0;i<N;i++) scanf ("%d",&A[i]);
	sort(A,A+N);
 
	long long ans = 0;
	for (int i=0,j=N-1,c=0;c<K;c++){
		if (c % 2 == 0){
			ans += A[j] - (i ? A[i-1] : 0);
			i++; j--;
		}
	}
 
	printf ("%lld\n",ans);
 
	return 0;
}

Compilation message

wine.cpp: In function 'int main()':
wine.cpp:9:10: warning: unused variable 'c' [-Wunused-variable]
  int N,K,c;
          ^
wine.cpp:11: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:12:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=0;i<N;i++) scanf ("%d",&A[i]);
                                          ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2288 KB Output is correct
2 Correct 0 ms 2288 KB Output is correct
3 Correct 0 ms 2288 KB Output is correct
4 Correct 0 ms 2288 KB Output is correct
5 Correct 0 ms 2288 KB Output is correct
6 Correct 0 ms 2288 KB Output is correct
7 Correct 0 ms 2288 KB Output is correct
8 Correct 0 ms 2288 KB Output is correct
9 Correct 0 ms 2288 KB Output is correct
10 Correct 0 ms 2288 KB Output is correct
11 Correct 0 ms 2288 KB Output is correct
12 Correct 0 ms 2288 KB Output is correct
13 Correct 0 ms 2288 KB Output is correct
14 Correct 0 ms 2288 KB Output is correct
15 Correct 0 ms 2288 KB Output is correct
16 Correct 0 ms 2288 KB Output is correct
17 Correct 3 ms 2288 KB Output is correct
18 Correct 3 ms 2288 KB Output is correct
19 Correct 6 ms 2288 KB Output is correct
20 Correct 6 ms 2288 KB Output is correct
21 Correct 16 ms 2288 KB Output is correct
22 Correct 26 ms 2288 KB Output is correct
23 Correct 36 ms 2288 KB Output is correct
24 Correct 36 ms 2288 KB Output is correct
25 Correct 83 ms 2288 KB Output is correct
26 Correct 96 ms 2288 KB Output is correct
27 Correct 103 ms 2288 KB Output is correct
28 Correct 49 ms 2288 KB Output is correct
29 Correct 83 ms 2288 KB Output is correct
30 Correct 79 ms 2288 KB Output is correct
31 Correct 96 ms 2288 KB Output is correct
32 Correct 79 ms 2288 KB Output is correct
33 Correct 0 ms 2288 KB Output is correct
34 Correct 16 ms 2288 KB Output is correct