結果
| 問題 |
No.941 商とあまり
|
| コンテスト | |
| ユーザー |
QCFium
|
| 提出日時 | 2019-09-06 14:27:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 919 bytes |
| コンパイル時間 | 297 ms |
| コンパイル使用メモリ | 82,208 KB |
| 実行使用メモリ | 259,276 KB |
| 最終ジャッジ日時 | 2024-11-21 04:47:08 |
| 合計ジャッジ時間 | 119,635 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 6 |
| other | WA * 67 TLE * 37 |
ソースコード
def solve(n, x, a):
if n == 1 : return x == a[0]
prod = 1
for i in range(n):
prod *= a[i] + 1
if prod > x + 1 : return False
if a[i] == 1 : 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")
QCFium