結果

問題 No.1330 Multiply or Divide
ユーザー chineristACchineristAC
提出日時 2021-01-08 23:08:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,754 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 119,936 KB
最終ジャッジ日時 2024-04-28 06:25:37
合計ジャッジ時間 31,307 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
58,624 KB
testcase_01 AC 1,443 ms
109,440 KB
testcase_02 AC 43 ms
51,840 KB
testcase_03 AC 43 ms
52,096 KB
testcase_04 AC 42 ms
51,840 KB
testcase_05 AC 50 ms
59,008 KB
testcase_06 AC 86 ms
97,280 KB
testcase_07 AC 1,754 ms
108,928 KB
testcase_08 AC 1,403 ms
117,660 KB
testcase_09 AC 1,510 ms
117,724 KB
testcase_10 AC 1,241 ms
117,988 KB
testcase_11 AC 1,506 ms
118,360 KB
testcase_12 AC 1,389 ms
117,864 KB
testcase_13 AC 52 ms
59,904 KB
testcase_14 AC 52 ms
59,904 KB
testcase_15 AC 50 ms
59,264 KB
testcase_16 AC 52 ms
59,648 KB
testcase_17 AC 51 ms
59,648 KB
testcase_18 AC 1,438 ms
117,472 KB
testcase_19 AC 1,442 ms
117,728 KB
testcase_20 AC 1,438 ms
117,732 KB
testcase_21 AC 1,441 ms
118,112 KB
testcase_22 AC 1,435 ms
117,844 KB
testcase_23 AC 1,219 ms
117,376 KB
testcase_24 AC 50 ms
59,392 KB
testcase_25 AC 50 ms
59,008 KB
testcase_26 AC 49 ms
59,392 KB
testcase_27 AC 42 ms
51,968 KB
testcase_28 AC 50 ms
59,136 KB
testcase_29 AC 49 ms
59,136 KB
testcase_30 AC 48 ms
58,496 KB
testcase_31 AC 50 ms
59,136 KB
testcase_32 AC 50 ms
59,136 KB
testcase_33 AC 50 ms
59,136 KB
testcase_34 AC 1,092 ms
105,344 KB
testcase_35 AC 346 ms
84,224 KB
testcase_36 AC 972 ms
107,136 KB
testcase_37 AC 873 ms
105,600 KB
testcase_38 AC 570 ms
93,312 KB
testcase_39 AC 413 ms
85,888 KB
testcase_40 AC 483 ms
89,088 KB
testcase_41 AC 276 ms
81,024 KB
testcase_42 AC 812 ms
102,144 KB
testcase_43 AC 951 ms
106,112 KB
testcase_44 AC 1,251 ms
119,680 KB
testcase_45 AC 1,392 ms
119,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

B = []
for a in A:
    cost = 1
    while a%P==0:
        a //= P
        cost += 1
    if a!=1:
        B.append((cost,a))

n = len(B)
dp = [1 for i in range(701)]
for i in range(n):
    cost,a = B[i]
    next = [dp[j] for j in range(701)]
    for j in range(701-cost):
        next[j+cost] = max(next[j+cost],min(M+1,dp[j]*a),min(M+1,next[j]*a))
    dp = next

K = max(A)
for i in range(701):
    if dp[i]*K >= M+1:
        print(i+1)
        break
else:
    print(-1)
0