Ding Dong Ditch (4/5 groups, 65/100 points)
This commit is contained in:
20
dingdongditch.py
Normal file
20
dingdongditch.py
Normal file
@@ -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))
|
||||||
Reference in New Issue
Block a user