結果

問題 No.1330 Multiply or Divide
ユーザー convexineqconvexineq
提出日時 2021-01-08 21:54:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 413 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 114,944 KB
最終ジャッジ日時 2024-04-28 06:19:16
合計ジャッジ時間 5,526 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,096 KB
testcase_01 AC 121 ms
113,152 KB
testcase_02 AC 42 ms
51,840 KB
testcase_03 AC 40 ms
51,840 KB
testcase_04 AC 41 ms
51,584 KB
testcase_05 AC 41 ms
51,712 KB
testcase_06 AC 105 ms
109,952 KB
testcase_07 AC 266 ms
114,944 KB
testcase_08 AC 129 ms
105,412 KB
testcase_09 AC 131 ms
105,152 KB
testcase_10 AC 132 ms
105,660 KB
testcase_11 AC 128 ms
105,400 KB
testcase_12 AC 130 ms
105,532 KB
testcase_13 AC 41 ms
52,096 KB
testcase_14 AC 41 ms
52,096 KB
testcase_15 AC 41 ms
51,712 KB
testcase_16 AC 41 ms
51,840 KB
testcase_17 AC 41 ms
51,584 KB
testcase_18 AC 119 ms
105,404 KB
testcase_19 AC 119 ms
105,412 KB
testcase_20 AC 119 ms
104,900 KB
testcase_21 AC 121 ms
105,268 KB
testcase_22 AC 120 ms
105,644 KB
testcase_23 AC 124 ms
105,228 KB
testcase_24 AC 41 ms
51,968 KB
testcase_25 AC 41 ms
51,584 KB
testcase_26 AC 41 ms
51,968 KB
testcase_27 AC 41 ms
52,352 KB
testcase_28 AC 41 ms
51,712 KB
testcase_29 AC 40 ms
51,840 KB
testcase_30 AC 40 ms
51,712 KB
testcase_31 AC 41 ms
52,224 KB
testcase_32 AC 41 ms
51,840 KB
testcase_33 AC 41 ms
51,712 KB
testcase_34 AC 97 ms
103,552 KB
testcase_35 AC 62 ms
70,912 KB
testcase_36 AC 89 ms
98,432 KB
testcase_37 AC 85 ms
94,336 KB
testcase_38 AC 70 ms
81,024 KB
testcase_39 AC 61 ms
73,088 KB
testcase_40 AC 66 ms
76,672 KB
testcase_41 AC 57 ms
67,328 KB
testcase_42 AC 81 ms
90,496 KB
testcase_43 AC 86 ms
95,488 KB
testcase_44 AC 125 ms
107,776 KB
testcase_45 AC 158 ms
108,160 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