結果

問題 No.10 +か×か
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-11-28 09:09:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 981 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 42,608 KB
最終ジャッジ日時 2024-04-15 10:55:11
合計ジャッジ時間 6,780 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
11,648 KB
testcase_01 AC 45 ms
11,648 KB
testcase_02 AC 45 ms
11,648 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from collections import defaultdict
    import sys,math
    
    input = sys.stdin.readline
    
    N = int(input())
    T = int(input())
    A = list(map(int,input().split()))
    X = defaultdict(int)
    M = 10**5+5
    called = [0]*M
    called[A[0]]=1
    for i in range(N-1):
        
        target = []
        for j in range(M):
            if called[j]==i+1:
                target.append((X[j],j))
        target.sort()
        n = len(target)
        a = A[i+1]
        for x,j in target:
            if j+a<M:
                if called[j+a]==i+2:
                    continue
                called[j+a]=i+2
                X[j+a] = x
            if j*a<M:
                if called[j*a]==i+2:
                    continue
                called[j*a]=i+2
                X[j*a] = x + (1<<N-2-i)
    def f(x):
        if x=='0':
            return '+'
        else:
            return '*'
    print(''.join(map(f,list(bin(X[T])[2:].zfill(N-1)))))
main()
0