結果

問題 No.1330 Multiply or Divide
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-01-08 21:40:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 120,704 KB
最終ジャッジ日時 2024-04-28 02:31:41
合計ジャッジ時間 5,140 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
51,584 KB
testcase_01 AC 106 ms
120,576 KB
testcase_02 WA -
testcase_03 AC 40 ms
52,096 KB
testcase_04 AC 34 ms
52,096 KB
testcase_05 AC 35 ms
52,352 KB
testcase_06 AC 88 ms
113,152 KB
testcase_07 AC 299 ms
120,704 KB
testcase_08 AC 116 ms
113,856 KB
testcase_09 AC 118 ms
113,992 KB
testcase_10 AC 124 ms
114,192 KB
testcase_11 AC 117 ms
114,056 KB
testcase_12 AC 119 ms
114,508 KB
testcase_13 AC 39 ms
52,096 KB
testcase_14 AC 35 ms
52,224 KB
testcase_15 AC 35 ms
52,096 KB
testcase_16 AC 36 ms
51,968 KB
testcase_17 AC 36 ms
52,096 KB
testcase_18 AC 106 ms
113,864 KB
testcase_19 AC 108 ms
114,120 KB
testcase_20 AC 105 ms
113,740 KB
testcase_21 AC 105 ms
113,604 KB
testcase_22 AC 107 ms
113,804 KB
testcase_23 WA -
testcase_24 AC 37 ms
51,712 KB
testcase_25 AC 37 ms
51,968 KB
testcase_26 WA -
testcase_27 AC 34 ms
51,584 KB
testcase_28 AC 34 ms
52,224 KB
testcase_29 AC 35 ms
51,456 KB
testcase_30 AC 35 ms
51,968 KB
testcase_31 AC 37 ms
52,096 KB
testcase_32 AC 36 ms
51,456 KB
testcase_33 AC 34 ms
52,268 KB
testcase_34 AC 86 ms
108,484 KB
testcase_35 AC 53 ms
72,484 KB
testcase_36 AC 91 ms
102,528 KB
testcase_37 AC 76 ms
97,536 KB
testcase_38 AC 64 ms
83,112 KB
testcase_39 AC 54 ms
74,880 KB
testcase_40 AC 60 ms
78,336 KB
testcase_41 AC 50 ms
68,480 KB
testcase_42 AC 74 ms
93,824 KB
testcase_43 AC 80 ms
98,688 KB
testcase_44 AC 149 ms
115,456 KB
testcase_45 AC 156 ms
115,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

dp[i] = i回の操作で行ける最大値

"""


from sys import stdin
import sys

N,M,P = map(int,stdin.readline().split())
A = list(map(int,stdin.readline().split()))
B = []
cnt = [0] * N

for i in range(N):
    na = A[i]
    while na % P == 0:
        na //= P
        cnt[i] += 1
    B.append(na)

if max(B) == 1 and max(A) < M:
    print (-1)
    sys.exit()

dp = [1] * 1001
for i in range(1000):
    
    nmax = dp[i]
    if nmax >= M:
        print (i)
        break

    for j in range(N):
        if nmax * A[j] >= M:
            print (i+1)
            sys.exit()
        else:
            dp[i+1+cnt[j]] = max(dp[i+1+cnt[j]] , dp[i]*B[j])
        
0