結果

問題 No.1330 Multiply or Divide
ユーザー chineristACchineristAC
提出日時 2021-01-08 23:08:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,748 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 965 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 121,008 KB
最終ジャッジ日時 2023-08-10 13:12:27
合計ジャッジ時間 33,274 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
76,044 KB
testcase_01 AC 1,444 ms
108,080 KB
testcase_02 AC 74 ms
71,376 KB
testcase_03 AC 75 ms
71,416 KB
testcase_04 AC 74 ms
71,212 KB
testcase_05 AC 78 ms
76,072 KB
testcase_06 AC 108 ms
104,476 KB
testcase_07 AC 1,748 ms
107,860 KB
testcase_08 AC 1,427 ms
119,060 KB
testcase_09 AC 1,509 ms
119,312 KB
testcase_10 AC 1,261 ms
119,076 KB
testcase_11 AC 1,512 ms
119,036 KB
testcase_12 AC 1,407 ms
118,896 KB
testcase_13 AC 78 ms
75,892 KB
testcase_14 AC 79 ms
76,040 KB
testcase_15 AC 77 ms
76,136 KB
testcase_16 AC 78 ms
75,892 KB
testcase_17 AC 78 ms
76,116 KB
testcase_18 AC 1,433 ms
118,936 KB
testcase_19 AC 1,422 ms
118,924 KB
testcase_20 AC 1,455 ms
119,040 KB
testcase_21 AC 1,439 ms
118,820 KB
testcase_22 AC 1,419 ms
119,020 KB
testcase_23 AC 1,207 ms
121,008 KB
testcase_24 AC 77 ms
76,000 KB
testcase_25 AC 76 ms
76,088 KB
testcase_26 AC 76 ms
75,892 KB
testcase_27 AC 71 ms
71,308 KB
testcase_28 AC 77 ms
75,940 KB
testcase_29 AC 75 ms
75,992 KB
testcase_30 AC 75 ms
76,084 KB
testcase_31 AC 78 ms
76,180 KB
testcase_32 AC 78 ms
76,024 KB
testcase_33 AC 78 ms
76,204 KB
testcase_34 AC 1,111 ms
102,140 KB
testcase_35 AC 363 ms
85,560 KB
testcase_36 AC 981 ms
101,136 KB
testcase_37 AC 868 ms
102,332 KB
testcase_38 AC 573 ms
94,068 KB
testcase_39 AC 422 ms
86,748 KB
testcase_40 AC 493 ms
90,728 KB
testcase_41 AC 295 ms
82,060 KB
testcase_42 AC 825 ms
103,176 KB
testcase_43 AC 944 ms
100,384 KB
testcase_44 AC 1,249 ms
113,528 KB
testcase_45 AC 1,368 ms
113,368 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