You are viewing a single comment's thread. Return to all comments →
import sys from functools import reduce n = int(input().strip()) T = list(map(int, input().strip().split(' '))) V = list(map(int, input().strip().split(' '))) # Write Your Code Here crates = {} cost = [] for i in range(n): if T[i] not in crates.keys(): crates[T[i]] = V[i] else: cost.append(reduce(lambda x, y: x | y, crates.values())) crates = {} crates[T[i]] = V[i] print(sum(cost))
Shouldn't a crate have all unique Ti's? Why didn't this work? The question seemed simple at the first glance
Seems like cookies are disabled on this browser, please enable them to open this website
Candy Collection
You are viewing a single comment's thread. Return to all comments →
Shouldn't a crate have all unique Ti's? Why didn't this work? The question seemed simple at the first glance