結果

問題 No.505 カードの数式2
ユーザー lllllll88938494
提出日時 2022-09-13 22:31:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 447 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 54,380 KB
最終ジャッジ日時 2024-12-14 06:35:34
合計ジャッジ時間 2,736 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))

dp=[[0,0] for i in range(n+1)]

for i in range(n):
    t=[]
    t.append(dp[i][0] - a[i])
    t.append(dp[i][1] - a[i])
    t.append(dp[i][0] + a[i])
    t.append(dp[i][1] + a[i])
    t.append(dp[i][0] * a[i])
    t.append(dp[i][1] * a[i])
    if a[i] !=0:
        t.append(dp[i][0] // a[i])
        t.append(dp[i][1] // a[i])
    t.sort()
    dp[i+1][0]=t[0]
    dp[i+1][1]=t[-1]

print(dp[-1][1])
0