結果

問題 No.941 商とあまり
ユーザー QCFium
提出日時 2019-09-06 14:51:25
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 956 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 239,344 KB
最終ジャッジ日時 2024-11-21 04:49:10
合計ジャッジ時間 119,385 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 6
other WA * 67 TLE * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, x, a):
	if n == 1 : return x == a[0]
	prod = 1
	cnt1 = False
	for i in range(n):
		prod *= a[i] + 1
		if prod > x + 1 : return False
		if a[i] == 1 : cnt1 = True
	if cnt1 : return True
	
	que = {tuple(a)}
	while len(que) :
		next = set()
		finish = False
		for i in que :
			if len(i) == 1 : finish = True
			break
		if finish :
			for i in que :
				if i[0] == x : return True
			return False
		
		for i in que :
			prod = 1
			for j in i : prod *= j + 1
			for j, k in enumerate(i) :
				if j and k == i[j - 1] : continue
				for l, m in enumerate(i) :
					if l == j: continue
					cur = prod // (k + 1) // (m + 1)
					o = m + 1
					while (o * k + m + 1) * cur <= x + 1 :
						tmp = list(i)
						tmp[j] = o * k + m
						tmp.pop(l)
						tmp.sort()
						next.add(tuple(tmp))
						o += 1
						
		que = next
	return False
	

n, x = map(int, input().split())
a = list(map(int, input().split()))
print("YES" if solve(n, x, a) else "NO")
0