제출 #768336

#제출 시각아이디문제언어결과실행 시간메모리
768336iamjiamingliu은행 (IZhO14_bank)Pypy 3
71 / 100
1084 ms26356 KiB
input() salaries = list(map(int, input().split())) notes = list(map(int, input().split())) if len(salaries) > len(notes): print('NO') exit() combo_to_form = [[] for _ in range(len(salaries))] for i, val in enumerate(salaries): for subset in range(1 << len(notes)): if sum(notes[j] for j in range(subset.bit_length()) if (1 << j) & subset) == val: combo_to_form[i].append(subset) if not combo_to_form[i]: print('NO') exit() prev_subsets = {(1 << len(notes)) - 1} for i in range(len(salaries)): new_subsets = set() for prev in prev_subsets: for needed in combo_to_form[i]: if (prev & needed) == needed: new_subsets.add(prev - needed) if not new_subsets: print('NO') exit() prev_subsets = new_subsets print('YES')
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...