diff --git a/dingdongditch.py b/dingdongditch.py new file mode 100644 index 0000000..71365a9 --- /dev/null +++ b/dingdongditch.py @@ -0,0 +1,20 @@ +from functools import lru_cache + +_, _ = map(int, input().split()) +neighbours = sorted(map(int, input().split())) +friends = map(int, input().split()) +total = sum(neighbours) + + +@lru_cache(maxsize=None) +def angry_value(i: int) -> int: + global neighbours + global total + if i > len(neighbours): + return total + else: + return sum(neighbours[:friend]) + + +for friend in friends: + print(angry_value(friend))