結果

問題 No.505 カードの数式2
ユーザー nanaenanae
提出日時 2017-04-21 23:14:48
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 398 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 78,460 KB
最終ジャッジ日時 2023-09-27 23:16:49
合計ジャッジ時間 9,680 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,452 KB
testcase_01 AC 77 ms
75,812 KB
testcase_02 AC 587 ms
77,984 KB
testcase_03 AC 65 ms
71,340 KB
testcase_04 AC 64 ms
71,404 KB
testcase_05 AC 65 ms
71,344 KB
testcase_06 AC 63 ms
71,252 KB
testcase_07 AC 63 ms
71,252 KB
testcase_08 AC 64 ms
71,240 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 67 ms
71,080 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 66 ms
71,256 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 75 ms
75,744 KB
testcase_20 AC 82 ms
76,544 KB
testcase_21 AC 593 ms
77,924 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 617 ms
77,904 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def solve():
    def dfs(i, value):
        if i == n:
            nonlocal ans
            ans = max(ans, value)
            return

        dfs(i + 1, value + a[i])
        dfs(i + 1, value * a[i])
        dfs(i + 1, value - a[i])

    n = int(input())
    a = [int(i) for i in input().split()]
    ans = -(1<<30)

    dfs(0, 0)

    print(ans)

if __name__ == '__main__':
    solve()
0