結果

問題 No.10 +か×か
ユーザー convexineqconvexineq
提出日時 2020-12-06 21:24:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 157 ms / 5,000 ms
コード長 424 bytes
コンパイル時間 1,567 ms
コンパイル使用メモリ 86,808 KB
実行使用メモリ 115,548 KB
最終ジャッジ日時 2023-08-21 06:32:37
合計ジャッジ時間 2,386 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,480 KB
testcase_01 AC 69 ms
71,296 KB
testcase_02 AC 72 ms
71,468 KB
testcase_03 AC 155 ms
115,420 KB
testcase_04 AC 104 ms
102,008 KB
testcase_05 AC 70 ms
71,436 KB
testcase_06 AC 157 ms
115,548 KB
testcase_07 AC 116 ms
102,168 KB
testcase_08 AC 93 ms
83,620 KB
testcase_09 AC 93 ms
90,040 KB
testcase_10 AC 73 ms
75,760 KB
testcase_11 AC 73 ms
75,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
t = int(input())
*a, = map(int,input().split())

dp = [-1]*(t+1) # +: 1 *: 0
dp[a[0]] = 0
for ai in a[1:]:
    ndp = [-1]*(t+1)
    for i,xi in enumerate(dp):
        if xi==-1: continue
        if i*ai <= t:
            ndp[i*ai] = max(ndp[i*ai], xi*2)
        if i+ai <= t:
            ndp[i+ai] = max(ndp[i+ai], xi*2+1)
    dp = ndp

print("".join(["+" if dp[t]>>i&1 else "*" for i in range(n-2,-1,-1)]))
0