結果

問題 No.1463 Hungry Kanten
ユーザー 小野寺健
提出日時 2021-04-29 14:23:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 711 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 51,488 KB
最終ジャッジ日時 2024-07-08 13:42:33
合計ジャッジ時間 6,719 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import copy

N, K = map(int, input().split())
A = list(map(int, input().split()))

sumA = sum(A)
prodA = np.prod(np.array(A))

ans = [sumA]
if sumA != prodA:
    ans.append(prodA)

q = [(A, sumA, prodA)]

cnt = N - K
while cnt > 0:
    new_q = []
    for an, s, p in q:
        for a in an:
            isAdd = False
            if s-a not in ans:
                ans.append(s-a)
                isAdd = True
            if p//a not in ans:
                ans.append(p//a)
                isAdd = True
            if isAdd:
                new_an = copy.copy(an)
                new_an.remove(a)
                new_q.append((new_an, s-a, p//a))  
    q = new_q
    cnt -= 1

print(len(ans))
0