結果

問題 No.505 カードの数式2
ユーザー lllllll88938494lllllll88938494
提出日時 2022-09-13 22:47:51
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 86,932 KB
実行使用メモリ 71,460 KB
最終ジャッジ日時 2023-08-20 23:52:44
合計ジャッジ時間 4,296 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,208 KB
testcase_01 AC 69 ms
71,100 KB
testcase_02 AC 70 ms
71,412 KB
testcase_03 AC 68 ms
71,460 KB
testcase_04 AC 70 ms
71,272 KB
testcase_05 AC 69 ms
71,348 KB
testcase_06 AC 71 ms
70,972 KB
testcase_07 AC 70 ms
71,272 KB
testcase_08 AC 69 ms
71,400 KB
testcase_09 AC 70 ms
71,152 KB
testcase_10 AC 69 ms
71,152 KB
testcase_11 AC 70 ms
71,148 KB
testcase_12 AC 69 ms
71,164 KB
testcase_13 AC 69 ms
71,296 KB
testcase_14 AC 69 ms
71,276 KB
testcase_15 AC 68 ms
71,052 KB
testcase_16 AC 68 ms
71,248 KB
testcase_17 AC 70 ms
71,268 KB
testcase_18 AC 69 ms
71,360 KB
testcase_19 AC 70 ms
71,244 KB
testcase_20 AC 70 ms
71,380 KB
testcase_21 AC 69 ms
71,080 KB
testcase_22 AC 69 ms
71,120 KB
testcase_23 AC 69 ms
71,248 KB
testcase_24 AC 68 ms
71,176 KB
testcase_25 AC 69 ms
71,252 KB
testcase_26 AC 68 ms
71,136 KB
testcase_27 AC 69 ms
71,396 KB
testcase_28 AC 69 ms
71,256 KB
testcase_29 AC 70 ms
71,400 KB
testcase_30 AC 72 ms
71,164 KB
testcase_31 AC 68 ms
71,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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

print(dp[-1][1])

# for i in dp:
#     print(i)
    
0