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: 307ms
Memory: 25316kB
Author: 13858900561
In contest: 1300

t=int(input())
for i in range(t):
    n,k,m=map(int,input().split())
    lst=list(map(int,input().split()))
    lst.sort()
    sum=0
    for j in range(k):
        sum+=lst[j]
    if sum>n:
        print(sum-n)
    else:
        print("0")