Start: Apr, 17, 2017 10:00:00
Python程序设计基础培训第四次作业
End: Apr, 23, 2017 14:00:00
Time elapsed:
Time remaining:

Problem_ID: A
Result: Accepted
Time: 611ms
Memory: 21428kB
Author: leo
In contest: 1088

T=input()
for i in range(T):
	n,k,m=map(int,raw_input().strip().split())
	a=map(int,raw_input().strip().split())
	a.sort()
	s=0
	for bi in a[0:k]:
		s=s+bi
	if s>n:
		print s-n
	else:
		print 0