結果

問題 No.1330 Multiply or Divide
ユーザー roarisroaris
提出日時 2021-06-04 17:44:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 86,680 KB
実行使用メモリ 108,536 KB
最終ジャッジ日時 2023-08-12 06:10:55
合計ジャッジ時間 9,051 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
76,908 KB
testcase_01 AC 164 ms
107,100 KB
testcase_02 AC 90 ms
71,392 KB
testcase_03 AC 101 ms
77,204 KB
testcase_04 AC 101 ms
76,832 KB
testcase_05 AC 99 ms
77,392 KB
testcase_06 AC 130 ms
105,152 KB
testcase_07 AC 147 ms
107,188 KB
testcase_08 AC 162 ms
108,412 KB
testcase_09 AC 175 ms
108,268 KB
testcase_10 AC 167 ms
108,256 KB
testcase_11 AC 162 ms
108,536 KB
testcase_12 AC 163 ms
108,280 KB
testcase_13 AC 116 ms
77,832 KB
testcase_14 AC 109 ms
77,072 KB
testcase_15 AC 108 ms
77,352 KB
testcase_16 AC 115 ms
78,568 KB
testcase_17 AC 104 ms
77,064 KB
testcase_18 AC 142 ms
108,240 KB
testcase_19 AC 142 ms
108,404 KB
testcase_20 AC 142 ms
108,304 KB
testcase_21 AC 141 ms
108,240 KB
testcase_22 AC 143 ms
108,424 KB
testcase_23 AC 142 ms
108,444 KB
testcase_24 AC 99 ms
76,952 KB
testcase_25 AC 90 ms
71,128 KB
testcase_26 AC 99 ms
77,108 KB
testcase_27 AC 92 ms
71,376 KB
testcase_28 AC 90 ms
71,392 KB
testcase_29 AC 90 ms
71,380 KB
testcase_30 AC 92 ms
71,376 KB
testcase_31 AC 102 ms
76,944 KB
testcase_32 AC 101 ms
76,968 KB
testcase_33 AC 93 ms
71,356 KB
testcase_34 AC 134 ms
100,980 KB
testcase_35 AC 106 ms
82,216 KB
testcase_36 AC 136 ms
97,944 KB
testcase_37 AC 126 ms
95,376 KB
testcase_38 AC 116 ms
87,968 KB
testcase_39 AC 110 ms
83,204 KB
testcase_40 AC 111 ms
85,184 KB
testcase_41 AC 106 ms
79,908 KB
testcase_42 AC 123 ms
93,372 KB
testcase_43 AC 124 ms
95,584 KB
testcase_44 AC 136 ms
105,000 KB
testcase_45 AC 132 ms
105,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

N, M, P = map(int, input().split())
A = list(map(int, input().split()))
Ma = max(A)
d = defaultdict(int)

for Ai in A:
    cost = 1
    
    while Ai%P==0:
        cost += 1
        Ai //= P
    
    d[cost] = max(d[cost], Ai)

dp = [0]*1000
dp[0] = 1

for i in range(1000):
    for k, v in d.items():
        if i+k<1000:
            dp[i+k] = max(dp[i+k], dp[i]*v)

for i in range(1000):
    if dp[i]*Ma>M:
        exit(print(i+1))

print(-1)
0