結果

問題 No.1330 Multiply or Divide
ユーザー brthyyjpbrthyyjp
提出日時 2022-02-03 15:39:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 324 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 108,112 KB
最終ジャッジ日時 2023-09-02 03:18:47
合計ジャッジ時間 9,264 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
77,188 KB
testcase_01 AC 158 ms
107,920 KB
testcase_02 AC 96 ms
77,188 KB
testcase_03 AC 100 ms
77,504 KB
testcase_04 AC 95 ms
77,400 KB
testcase_05 AC 104 ms
77,580 KB
testcase_06 AC 133 ms
105,896 KB
testcase_07 AC 148 ms
107,412 KB
testcase_08 AC 267 ms
107,200 KB
testcase_09 AC 324 ms
106,460 KB
testcase_10 AC 267 ms
106,420 KB
testcase_11 AC 235 ms
106,524 KB
testcase_12 AC 269 ms
106,872 KB
testcase_13 AC 212 ms
103,976 KB
testcase_14 AC 163 ms
88,544 KB
testcase_15 AC 134 ms
87,004 KB
testcase_16 AC 188 ms
95,344 KB
testcase_17 AC 124 ms
81,072 KB
testcase_18 AC 174 ms
106,372 KB
testcase_19 AC 171 ms
106,272 KB
testcase_20 AC 168 ms
106,288 KB
testcase_21 AC 175 ms
106,244 KB
testcase_22 AC 172 ms
106,460 KB
testcase_23 AC 174 ms
108,112 KB
testcase_24 AC 106 ms
77,860 KB
testcase_25 AC 102 ms
77,588 KB
testcase_26 AC 103 ms
77,752 KB
testcase_27 AC 99 ms
77,368 KB
testcase_28 AC 100 ms
77,700 KB
testcase_29 AC 103 ms
77,692 KB
testcase_30 AC 102 ms
77,580 KB
testcase_31 AC 105 ms
77,476 KB
testcase_32 AC 101 ms
77,656 KB
testcase_33 AC 100 ms
77,588 KB
testcase_34 AC 165 ms
101,788 KB
testcase_35 AC 134 ms
94,116 KB
testcase_36 AC 160 ms
98,948 KB
testcase_37 AC 155 ms
98,008 KB
testcase_38 AC 140 ms
92,020 KB
testcase_39 AC 134 ms
93,604 KB
testcase_40 AC 138 ms
92,492 KB
testcase_41 AC 134 ms
94,704 KB
testcase_42 AC 156 ms
98,200 KB
testcase_43 AC 157 ms
98,344 KB
testcase_44 AC 136 ms
105,852 KB
testcase_45 AC 136 ms
105,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, p = map(int, input().split())
A = list(map(int, input().split()))

from collections import defaultdict
C = defaultdict(lambda: 0)
D = []
for a in A:
    b = a
    cost = 1
    while a%p == 0:
        cost += 1
        a //= p
    C[cost] = max(C[cost], a)

M = max(A)

N = 3000
dp = [0]*(N+1)

dp[0] = 1
for c, a in C.items():
    for i in range(N+1):
        if i+c <= N:
            dp[i+c] = max(dp[i+c], dp[i]*a)
ans = 10**18
for i, x in enumerate(dp):
    if x*M> m:
        ans = min(ans, i+1)
if ans != 10**18:
    print(ans)
else:
    print(-1)
0