結果

問題 No.1330 Multiply or Divide
ユーザー titiatitia
提出日時 2021-01-08 22:09:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 514 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 109,488 KB
最終ジャッジ日時 2023-08-10 13:06:54
合計ジャッジ時間 8,470 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
77,180 KB
testcase_01 AC 148 ms
109,468 KB
testcase_02 AC 102 ms
76,916 KB
testcase_03 AC 107 ms
77,256 KB
testcase_04 AC 105 ms
77,304 KB
testcase_05 AC 105 ms
77,152 KB
testcase_06 AC 145 ms
108,612 KB
testcase_07 AC 159 ms
109,488 KB
testcase_08 AC 182 ms
104,356 KB
testcase_09 AC 185 ms
104,132 KB
testcase_10 AC 184 ms
104,180 KB
testcase_11 AC 169 ms
104,172 KB
testcase_12 AC 185 ms
104,380 KB
testcase_13 AC 117 ms
77,212 KB
testcase_14 AC 121 ms
77,148 KB
testcase_15 AC 130 ms
77,144 KB
testcase_16 AC 123 ms
77,288 KB
testcase_17 AC 133 ms
77,156 KB
testcase_18 AC 156 ms
103,924 KB
testcase_19 AC 155 ms
104,276 KB
testcase_20 AC 157 ms
104,176 KB
testcase_21 AC 163 ms
103,932 KB
testcase_22 AC 163 ms
104,372 KB
testcase_23 AC 154 ms
106,228 KB
testcase_24 AC 102 ms
76,804 KB
testcase_25 AC 102 ms
77,196 KB
testcase_26 AC 106 ms
77,180 KB
testcase_27 AC 105 ms
77,116 KB
testcase_28 AC 105 ms
77,240 KB
testcase_29 AC 102 ms
76,904 KB
testcase_30 AC 111 ms
77,196 KB
testcase_31 AC 104 ms
77,028 KB
testcase_32 AC 107 ms
76,820 KB
testcase_33 AC 103 ms
77,304 KB
testcase_34 AC 141 ms
103,368 KB
testcase_35 AC 116 ms
82,776 KB
testcase_36 AC 143 ms
100,024 KB
testcase_37 AC 132 ms
97,292 KB
testcase_38 AC 123 ms
88,832 KB
testcase_39 AC 117 ms
84,056 KB
testcase_40 AC 121 ms
86,448 KB
testcase_41 AC 113 ms
80,620 KB
testcase_42 AC 133 ms
95,652 KB
testcase_43 AC 142 ms
97,848 KB
testcase_44 AC 154 ms
108,600 KB
testcase_45 AC 144 ms
108,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

B=[0]*N
C=[0]*N

for i in range(N):
    a=A[i]
    while a%P==0:
        B[i]+=1
        a//=P
    C[i]=a

K=[0]*50

for i in range(N):
    K[B[i]]=max(K[B[i]],C[i])


DP=[0]*100000
DP[0]=1

for i in range(95000):
    for j in range(49,-1,-1):
        DP[i+j+1]=min(10**9+1,max(DP[i+j+1],DP[i]*K[j]))

MAX=max(A)
for i in range(100000):
    if DP[i]>M/MAX:
        print(i+1)
        break
else:
    print(-1)
0