Submission #768344

#TimeUsernameProblemLanguageResultExecution timeMemory
768344iamjiamingliuBank (IZhO14_bank)Pypy 3
19 / 100
376 ms35964 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, 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]] new_amount = left_over[prev_subset] + bank[elem] if new_amount == target_val: ppl_satisfied[cur_subset] = ppl_satisfied[prev_subset] + 1 left_over[cur_subset] = 0 elif new_amount < target_val: ppl_satisfied[cur_subset] = ppl_satisfied[prev_subset] left_over[cur_subset] = new_amount 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...