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