結果

問題 No.505 カードの数式2
ユーザー nebukuro09
提出日時 2017-04-21 22:45:01
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 363 bytes
コンパイル時間 1,336 ms
コンパイル使用メモリ 76,788 KB
実行使用メモリ 83,328 KB
最終ジャッジ日時 2024-07-20 05:34:42
合計ジャッジ時間 5,114 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product

N = input()
A = map(int, raw_input().split())
ans = float('-inf')

for c in product('+-*', repeat=N-1):
    a = A[0]
    for i in xrange(N-1):
        if c[i] == '+':
            a = a + A[i+1]
        elif c[i] == '-':
            a = a - A[i+1]
        elif c[i] == '*':
            a = a * A[i+1]
    ans = max(ans, a)
print ans
0