結果

問題 No.297 カードの数式
コンテスト
ユーザー tjake
提出日時 2015-12-19 15:30:05
言語 PyPy2
(7.3.20)
結果
RE  
実行時間 -
コード長 373 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 126 ms
コンパイル使用メモリ 77,348 KB
最終ジャッジ日時 2025-12-03 18:43:28
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 RE * 1 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from itertools import permutations
n = input()
c = raw_input().split()
mi = 10**9
ma = -10**9
join = ''.join
for p in permutations(c):
    if p[0] in "+-" or p[-1] in "+-": continue
    for i in xrange(n-1):
        if p[i] in "+-" and p[i+1] in "+-":
            break
    else:
        res = eval(join(p))
        mi = min(mi, res)
        ma = max(ma, res)
print ma, mi
0