Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solve(l,ans, K, store, skillset):
- if (ans == K):
- cost=0
- maxbrush=0
- for i in range(len(store)):
- cost+=stipend[store[i][1]]
- maxbrush=max(maxbrush,brushes[store[i][1]])
- cost+=k*maxbrush
- costarr.append(cost)
- return
- for i in range(l, len(skillset), 1):
- if (ans + skillset[i] > K):
- continue
- if (i > l and skillset[i] == skillset[i - 1]):
- continue
- store.append([skillset[i],i])
- solve(i + 1, ans + skillset[i],K, store, skillset)
- store.remove(store[len(store) - 1])
- m=int(input())
- n=int(input())
- k=int(input())
- stipend=[]
- brushes=[]
- skills=[]
- costarr=[]
- maxbrush=0
- for i in range(n):
- stipend.append(int(input()))
- for i in range(n):
- brushes.append(int(input()))
- for i in range(n):
- skills.append(int(input(),2))
- mx = int("1"*m,2)
- skills.sort()
- temp=[]
- solve(0,0,mx,temp,skills)
- if len(costarr)==0:print(-1)
- else:
- print(min(costarr))
Advertisement
Add Comment
Please, Sign In to add comment