結果

問題 No.1330 Multiply or Divide
ユーザー roarisroaris
提出日時 2021-06-04 17:44:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 105,472 KB
最終ジャッジ日時 2024-04-29 20:42:14
合計ジャッジ時間 5,989 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
61,440 KB
testcase_01 AC 107 ms
105,216 KB
testcase_02 AC 47 ms
54,144 KB
testcase_03 AC 55 ms
61,184 KB
testcase_04 AC 56 ms
62,208 KB
testcase_05 AC 54 ms
62,080 KB
testcase_06 AC 95 ms
99,072 KB
testcase_07 AC 114 ms
105,472 KB
testcase_08 AC 137 ms
100,888 KB
testcase_09 AC 147 ms
100,252 KB
testcase_10 AC 138 ms
100,880 KB
testcase_11 AC 134 ms
101,132 KB
testcase_12 AC 137 ms
100,768 KB
testcase_13 AC 83 ms
77,056 KB
testcase_14 AC 77 ms
76,160 KB
testcase_15 AC 68 ms
72,960 KB
testcase_16 AC 79 ms
76,544 KB
testcase_17 AC 63 ms
67,584 KB
testcase_18 AC 115 ms
99,092 KB
testcase_19 AC 115 ms
98,968 KB
testcase_20 AC 115 ms
98,968 KB
testcase_21 AC 116 ms
98,832 KB
testcase_22 AC 115 ms
99,224 KB
testcase_23 AC 116 ms
101,820 KB
testcase_24 AC 56 ms
61,952 KB
testcase_25 AC 49 ms
53,888 KB
testcase_26 AC 57 ms
62,208 KB
testcase_27 AC 52 ms
54,272 KB
testcase_28 AC 50 ms
54,272 KB
testcase_29 AC 52 ms
54,528 KB
testcase_30 AC 54 ms
54,656 KB
testcase_31 AC 58 ms
61,952 KB
testcase_32 AC 56 ms
61,824 KB
testcase_33 AC 50 ms
54,272 KB
testcase_34 AC 106 ms
99,584 KB
testcase_35 AC 69 ms
73,216 KB
testcase_36 AC 99 ms
97,536 KB
testcase_37 AC 91 ms
91,904 KB
testcase_38 AC 78 ms
80,896 KB
testcase_39 AC 69 ms
74,624 KB
testcase_40 AC 72 ms
77,440 KB
testcase_41 AC 65 ms
70,400 KB
testcase_42 AC 85 ms
89,216 KB
testcase_43 AC 94 ms
95,488 KB
testcase_44 AC 94 ms
98,816 KB
testcase_45 AC 93 ms
99,072 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