Submission #768343

#TimeUsernameProblemLanguageResultExecution timeMemory
768343iamjiamingliuBank (IZhO14_bank)Pypy 3
19 / 100
313 ms35796 KiB
input() people = list(map(int, input().split())) bank = list(map(int, input().split())) ppl_satisfied = [0] * (1 << len(bank)) left_over = [0] * (1 << len(bank)) for cur_subset in range(1 << len(bank)): for elem in range(len(bank)): if cur_subset & (1 << elem): prev_subset = cur_subset ^ (1 << elem) target_val = people[ppl_satisfied[prev_subset]] if left_over[prev_subset] + bank[elem] == target_val: ppl_satisfied[cur_subset] = ppl_satisfied[prev_subset] + 1 left_over[cur_subset] = 0 else: ppl_satisfied[cur_subset] = ppl_satisfied[prev_subset] left_over[cur_subset] = left_over[prev_subset] + bank[elem] if ppl_satisfied[cur_subset] == len(people): print('YES') exit() print('NO')
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...