結果

問題 No.1330 Multiply or Divide
ユーザー convexineqconvexineq
提出日時 2021-01-08 21:54:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 413 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 111,524 KB
最終ジャッジ日時 2023-08-10 13:05:44
合計ジャッジ時間 7,173 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,208 KB
testcase_01 AC 131 ms
104,280 KB
testcase_02 AC 72 ms
71,180 KB
testcase_03 AC 70 ms
71,400 KB
testcase_04 AC 70 ms
71,392 KB
testcase_05 AC 69 ms
71,464 KB
testcase_06 AC 122 ms
111,524 KB
testcase_07 AC 276 ms
106,292 KB
testcase_08 AC 143 ms
106,524 KB
testcase_09 AC 145 ms
106,696 KB
testcase_10 AC 144 ms
106,632 KB
testcase_11 AC 140 ms
106,276 KB
testcase_12 AC 141 ms
106,576 KB
testcase_13 AC 72 ms
71,048 KB
testcase_14 AC 72 ms
71,164 KB
testcase_15 AC 70 ms
71,204 KB
testcase_16 AC 72 ms
71,020 KB
testcase_17 AC 72 ms
71,172 KB
testcase_18 AC 134 ms
106,248 KB
testcase_19 AC 132 ms
106,360 KB
testcase_20 AC 130 ms
106,216 KB
testcase_21 AC 132 ms
106,408 KB
testcase_22 AC 131 ms
106,252 KB
testcase_23 AC 136 ms
106,188 KB
testcase_24 AC 72 ms
71,016 KB
testcase_25 AC 71 ms
71,388 KB
testcase_26 AC 71 ms
71,236 KB
testcase_27 AC 71 ms
71,172 KB
testcase_28 AC 71 ms
71,208 KB
testcase_29 AC 70 ms
71,324 KB
testcase_30 AC 71 ms
71,172 KB
testcase_31 AC 70 ms
71,016 KB
testcase_32 AC 71 ms
71,032 KB
testcase_33 AC 69 ms
71,244 KB
testcase_34 AC 118 ms
103,720 KB
testcase_35 AC 84 ms
82,584 KB
testcase_36 AC 110 ms
102,984 KB
testcase_37 AC 103 ms
99,500 KB
testcase_38 AC 91 ms
89,764 KB
testcase_39 AC 91 ms
84,276 KB
testcase_40 AC 89 ms
86,616 KB
testcase_41 AC 81 ms
80,192 KB
testcase_42 AC 100 ms
96,780 KB
testcase_43 AC 106 ms
99,828 KB
testcase_44 AC 144 ms
111,064 KB
testcase_45 AC 175 ms
111,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,p = map(int,input().split())
*a, = map(int,input().split())

ma = max(a)
t = [1]*n
for i in range(n):
    while a[i]%p==0:
        a[i] //= p
        t[i] += 1

if all(ai==1 for ai in a) and ma <= m:
    print(-1)
    exit()

m = (m+ma)//ma
N = 1024
dp = [1]*N
for i in range(N):
    if dp[i] >= m: break
    for ai,ti in zip(a,t):
        if i+ti < N:
            dp[i+ti] = max(dp[i+ti],dp[i]*ai)
print(i+1)
0