fork download
  1. # cook your dish here
  2. for j in range(int(input())):
  3. n,k=map(int,input().split())
  4. l=list(map(int,input().split()))
  5. l.sort()
  6. c=0
  7. i=0
  8. j=1
  9. while c==0:
  10. if min(l[i],l[j])>k:
  11. l[i]=l[i]-1
  12. l[j]=l[j]-1
  13. else:
  14. i+=1
  15. j+=1
  16. if j>n-1:
  17. break
  18. print(sum(l))
  19. # your code goes here
Runtime error #stdin #stdout #stderr 0.12s 23688KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 2, in <module>
EOFError: EOF when reading a line