Start: Jul, 06, 2019 10:00:00
20190706Python程序设计基础培训扩展练习
End: Jul, 17, 2019 12:00:00
Time elapsed:
Time remaining:

Problem_ID: A
Result: Accepted
Time: 308ms
Memory: 25308kB
Author: 2018212212099
In contest: 1300

t=int(input())
while t:
    n,k,m=map(int,input().split())
    a=list(map(int,input().split()))
    a.sort()
    iSum=0
    for i in range(k):
        iSum+=a[i]
    if iSum<=n:
        print(0)
    else:
        print(iSum-n)
    t=t-1