結果

問題 No.505 カードの数式2
ユーザー lloyzlloyz
提出日時 2022-11-12 00:00:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 532 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 10,672 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2023-10-11 18:12:08
合計ジャッジ時間 2,625 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,948 KB
testcase_01 AC 17 ms
7,780 KB
testcase_02 AC 16 ms
7,776 KB
testcase_03 AC 16 ms
7,836 KB
testcase_04 AC 16 ms
7,780 KB
testcase_05 AC 15 ms
7,928 KB
testcase_06 AC 15 ms
7,712 KB
testcase_07 AC 15 ms
7,708 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 15 ms
7,712 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 16 ms
7,808 KB
testcase_21 AC 16 ms
7,884 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

INF = 10**18
DP = [[0 for _ in range(4)] for _ in range(n + 1)]
for i in range(n):
    a = A[i]
    for j in range(4):
        if DP[i][j] == -INF:
            continue
        DP[i + 1][0] = max(DP[i + 1][0], DP[i][j] + a)
        DP[i + 1][1] = max(DP[i + 1][1], DP[i][j] - a)
        DP[i + 1][2] = max(DP[i + 1][2], DP[i][j] * a)
        if a == 0:
            DP[i + 1][3] == -INF
        else:
            DP[i + 1][3] = max(DP[i + 1][3], DP[i][3] // a)
print(max(DP[n]))
0