結果

問題 No.505 カードの数式2
ユーザー hedwig100
提出日時 2020-05-28 12:14:44
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 503 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 80,896 KB
最終ジャッジ日時 2024-10-13 04:06:34
合計ジャッジ時間 3,854 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

from itertools import permutations,product,combinations_with_replacement,groupby,accumulate,combinations
N = int(input())
A = list(map(int,input().split()))
ans = 0
for L in product((0,1,2),repeat = N - 1):
    ret = A[0]
    for i in range(N - 1):
        if L[i] == 0:
            ret += A[i + 1]
        elif L[i] == 1:
            ret -= A[i + 1]
        else:
            ret *= A[i + 1]
    ans = max(ans,ret)
print(ans)
0