Submission #29202

# Submission time Handle Problem Language Result Execution time Memory
29202 2017-07-18T16:09:46 Z dnsdhrj Wine Tasting (FXCUP2_wine) C++14
0 / 1
0 ms 4364 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <stack>
#include <deque>
 
using namespace std;
typedef long long ll;
typedef pair<int, int> Pi;
 
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()
 
#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
 
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))
#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)
 
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)
#define INF 987654321
#define IINF 7654321987654321
#define MOD 1000000
 
int N, M, K, T;
 
ll in[300005];
 
int main() {
	geti2(N, K);
	rep(i, N)
		scanf("%lld", &in[i]);
	sort(in, in+N);
	ll sum = 0;
	rep(i, (K+1) / 2)
		sum += in[i];
	rep(i, (K-1) / 2)
		sum -= in[N-i-1];
	printf("%lld", sum);
 
	return 0;
}

Compilation message

wine.cpp: In function 'int main()':
wine.cpp:53:13: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  geti2(N, K);
             ^
wine.cpp:55:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &in[i]);
                        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4364 KB Output is correct
2 Correct 0 ms 4364 KB Output is correct
3 Incorrect 0 ms 4364 KB Output isn't correct
4 Halted 0 ms 0 KB -