제출 #1098119

#제출 시각아이디문제언어결과실행 시간메모리
1098119vjudge1은행 (IZhO14_bank)Cpython 3
0 / 100
20 ms4444 KiB
import sys from collections import defaultdict sys.setrecursionlimit(10**6) n, m = map(int, input().split()) p = [0] * (n + 1) f = [0] * (m + 1) used = [[0] * (1 << m) for _ in range(n + 1)] g = defaultdict(list) for i in range(1, n + 1): p[i] = int(input()) for i in range(1, m + 1): f[i] = int(input()) for y in range(1, (1 << m)): a = 0 for j in range(m): if (y >> j) & 1: a += f[j + 1] if a <= 1000: g[a].append(y) def rec(pos, mask): if pos == n + 1: print("YES") sys.exit(0) if used[pos][mask]: return used[pos][mask] = 1 for i in g[p[pos]]: if (mask & i) == 0: rec(pos + 1, mask | i) rec(1, 0) 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...