1113 Integer Set Partition (25 point(s))

1113 Integer Set Partition (25 point(s))_第1张图片

#include
#include
#include
#include
using namespace std;
int n, sum, half;
int main() {
	scanf("%d", &n);
	vector res(n);
	for(int i = 0; i < n; ++i) scanf("%d", &res[i]), sum += res[i];
	sort(res.begin(), res.end());
	for(int i = 0; i < n / 2; ++i) half += res[i];
	printf("%d %d\n", n % 2, sum - 2 * half);
	return 0;
} 

 

你可能感兴趣的:(Pat甲级,Pat甲级)