Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inp = open("input.txt", "rb")
- n, k = [int(x) for x in inp.readline().split()]
- a = []
- for i in range(n):
- s = inp.readline() + b' '
- t = ""
- for j in s:
- if (j == ord('-')) and (len(t) == 0):
- t += chr(j)
- elif (j >= ord('0')) and (j <= ord('9')):
- t += chr(j)
- a.append(int(t))
- a.sort()
- #print(a)
- open("output.txt", "w").write(str(sum(a[:k])))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement